<template>
    <pageTabelLayout>
        <template #pageHeader>
            <div class="search-form isheader" v-if="headerShow">
                <div>
                    <a-form style="width: 100% !important" size="small" :model="queryData" layout="inline">
                        <a-form-item label="坯布编号" v-if="permissionStore.hasPermisson('pblb.dclcx') ||
                            permissionStore.hasPermisson('pblb.yclcx')
                            ">
                            <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                                v-model="pageData.dropDownData" @press-enter="huiche" />
                        </a-form-item>
                        <a-form-item label="坯布名称" v-if="permissionStore.hasPermisson('pblb.dclcx') ||
                            permissionStore.hasPermisson('pblb.yclcx')
                            ">
                            <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""
                                v-model="pageData.dropDownData2" @press-enter="huiche" />
                        </a-form-item>
                        <!--            <a-form-item label="产品类型" v-if="permissionStore.hasPermisson('pblb.dclcx') ||-->
                        <!--              permissionStore.hasPermisson('pblb.yclcx')-->
                        <!--              ">-->
                        <!--              <a-input allow-clear :style="{ width: '200px' }" class="bacClass" placeholder=""-->
                        <!--                v-model="pageData.dropDownData4" @press-enter="huiche" />-->
                        <!--            </a-form-item>-->
                    </a-form>
                </div>
                <div class="my-tool-bar">
                    <Toolbar v-if="shenhebiaoji == 1" :items="[
                        `${permissionStore.hasPermisson('pblb.dclcx') ? '查询' : ''}`,
                        `${permissionStore.hasPermisson('pblb.dclxz') ? '新增' : ''}`,
                        `${permissionStore.hasPermisson('pblb.dclsc') ? '删除' : ''}`,
                        `${permissionStore.hasPermisson('pblb.dclsh') ? '审核' : ''}`,
                    ]" @add="addHandler" @del="deleteHandler" @select="selectHandler" @audit="shenhe('待审核')">
                    </Toolbar>
                    <a-dropdown trigger="hover">
                        <Toolbar v-if="shenhebiaoji == 1" :items="[
                            `${permissionStore.hasPermisson('pblb.dclfz') ? '复制' : ''}`,
                        ]" @copy="wdfz">
                        </Toolbar>
                        <template #content>
                            <a-doption @click="fuzhixinzeng('工艺')">工艺</a-doption>
                            <a-doption @click="fuzhixinzeng('颜色')">颜色</a-doption>
                            <a-doption @click="fuzhixinzeng('工艺颜色')">工艺颜色</a-doption>
                        </template>
                    </a-dropdown>

                    <Toolbar v-if="shenhebiaoji == 2" :items="[
                        `${permissionStore.hasPermisson('pblb.yclcx') ? '查询' : ''}`,
                        `${permissionStore.hasPermisson('pblb.yclxz') ? '新增' : ''}`,
                        `${permissionStore.hasPermisson('pblb.yclsc') ? '删除' : ''}`,
                        `${permissionStore.hasPermisson('pblb.yclfs') ? '反审' : ''}`,
                    ]" @add="addHandler" @del="deleteHandler" @select="selectHandler" @counter="shenhe('已审核')">
                    </Toolbar>
                    <a-dropdown trigger="hover">
                        <Toolbar v-if="shenhebiaoji == 2" :items="[
                            `${permissionStore.hasPermisson('pblb.yclfz') ? '复制' : ''}`,
                        ]" @copy="wdfz">
                        </Toolbar>
                        <template #content>
                            <a-doption @click="fuzhixinzeng('工艺')">工艺</a-doption>
                            <a-doption @click="fuzhixinzeng('颜色')">颜色</a-doption>
                            <a-doption @click="fuzhixinzeng('工艺颜色')">工艺颜色</a-doption>
                        </template>
                    </a-dropdown>
                </div>
            </div>
            <div class="my-divisders">
                <a-divider orientation="center">
                    <icon-double-up v-if="headerShow" @click="headerShow = false" :strokeWidth="2" :size="18" />
                    <icon-double-down v-else @click="headerShow = true" :strokeWidth="2" :size="18" />
                </a-divider>
            </div>
        </template>

        <template #pageTabel>
            <a-tabs   :lazy-load="true" :justify="true" default-active-key="1" @change="handoff">
                <a-tab-pane title="待审核" key="1">
                    <a-spin :loading="pageData.pageLoading" tip="加载中" dot style="height: 100%; width: 100%; z-index: 999">
                        <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" rowSelection="multiple" @grid-ready="gridReady"
                            style="height: 95%" :defaultColDef="defaultColDef" class="ag-theme-alpine"
                            :rowData="table.dataList" :columnDefs="tc" :localeText="localeText1"></AgGridVuesCopys>
                    </a-spin>
                </a-tab-pane>

                <a-tab-pane title="已审核" key="2">
                    <a-spin :loading="pageData.pageLoading" tip="加载中" dot style="height: 100%; width: 100%; z-index: 999">
                        <AgGridVuesCopys :rowHeight="33" :headerHeight="33" :suppressCopyRowsToClipboard="true" rowSelection="multiple" @grid-ready="gridReady2"
                            style="height: 95%" :defaultColDef="defaultColDef" class="ag-theme-alpine"
                            :rowData="table.dataList" :columnDefs="tc2" :localeText="localeText1"></AgGridVuesCopys>
                    </a-spin>
                </a-tab-pane>
            </a-tabs>
        </template>
        <paginationCopys :page-size-options="pagingList1" :total="total" show-total show-jumper show-page-size
            @change="PageSize" @page-size-change="change1" style="justify-content: center" :page-size="size"
            :current="page" />
        <a-drawer ok-text="保存" cancel-text="关闭" :style="{ zIndex: 10000 }" :mask-closable="false"
            :ok-loading="pageData.pageLoading" unmount-on-close  height="100%"
            :visible="pageData.showAdd" placement="bottom" @cancel="pageData.showAdd = false">
            <template #title>
                {{ pageData.isDetails == true ? '详情' : pageData.sideTitle }}
            </template>
            <!-- 基本信息 -->
            <template #footer>
                <a-button @click="cancelPop"> 关闭 </a-button>
                <a-button type="primary" @click="sideOk" v-if="!pageData.isDetails"> 保存 </a-button>
            </template>
            <div style="min-width: 1500px; overflow: auto" class="scrollbar">
                <el-scrollbar>
                    <a-collapse :default-active-key="[1]">
                        <a-collapse-item header="基本信息" :key="1">
                            <a-form style="padding-left: 40px" size="mini" ref="formRef" layout="inline" :model="dataForm">
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="坯布编号"
                                    field="greyCode" :disabled="dataForm.processType == 0 && pageData.isDetails == false ? true : false
                                        ">
                                    <a-input :class="{ bacClass: true }" :disabled="pageData.isDetails"
                                        :style="{ width: '250px' }" v-model="dataForm.greyCode"></a-input>
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="是否本集团"
                                    field="processType" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '是否本集团必选' }]"
                                    :validate-trigger="['change', 'blur']">
                                    <a-select popup-container="html"  :style="{ width: '250px' }" :class="{ bacClass: true }" disabled
                                        v-model="dataForm.processType" @change="codeGen">
                                        <a-option :value="0">本集团</a-option>
                                        <a-option :value="1">外加工</a-option>
                                    </a-select>
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="120px" label="坯布功能位代号"
                                    field="feature" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '功能必选' }]">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" @change="codeGen" v-model="dataForm.feature"
                                        allow-clear allow-search @search="gnSelect" @focus="focusGn">
                                        <a-option v-for="item in gnList" :value="item.greyInformationName">
                                            {{ item.greyInformationName }}
                                        </a-option>
                                    </a-select>
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="纱线类别"
                                    field="yarnCountCategory" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '纱线类别必选' }]">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" @change="codeGen" allow-search allow-clear
                                        @search="szSelect" @focus="szSelect" v-model="dataForm.yarnCountCategory">
                                        <a-option v-for="item in szList" :value="item.yarnName">{{ item.yarnName }}
                                        </a-option>
                                    </a-select>
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="成品克重"
                                    field="finishedWeight" :disabled="pageData.isDetails">
                                    <a-input :class="{ bacClass: true }" v-model="dataForm.finishedWeight" />
                                </a-form-item>
                                <a-form-item :style="{ width: '1372px' }" label-col-flex="100px" label="坯布名称"
                                    field="grayFabricName" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '坯布名称必填' }]" :validate-trigger="['change', 'blur']">
                                    <a-input :class="{ bacClass: true }" v-model="dataForm.grayFabricName" />
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="布类" field="mercery"
                                    :rules="[{ required: true, message: '布类必选' }]" :disabled="pageData.isDetails">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" @change="codeGen" allow-clear allow-search
                                        @search="blSelect" v-model="dataForm.mercery" @focus="focusBl">
                                        <a-option v-for="item in blList" :value="item.merceryName">{{ item.merceryName }}
                                        </a-option>
                                    </a-select>
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="英文名称"
                                    field="englishName" :disabled="pageData.isDetails">
                                    <a-input :class="{ bacClass: true }" v-model="dataForm.englishName" />
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="开发编号"
                                    field="exploitCode" :rules="[{ validator: ExploitCodeRules }]"
                                    :disabled="pageData.isDetails" :validate-trigger="['change', 'blur']">
                                    <a-input :class="{ bacClass: true }" v-model="dataForm.exploitCode" />
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="备案编号"
                                    field="putOnRecordsCode" :disabled="pageData.isDetails"
                                    :rules="[{ validator: putOnRecordsCodeRules }]" :validate-trigger="['change', 'blur']">
                                    <a-input :class="{ bacClass: true }" v-model="dataForm.putOnRecordsCode" />
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="是否抽针"
                                    field="drawnNeedleState" :disabled="pageData.isDetails">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" v-model="dataForm.drawnNeedleState" allowClear>
                                        <a-option :value="2"> </a-option>
                                        <a-option :value="0">圆筒</a-option>
                                        <a-option :value="1">抽针</a-option>
                                    </a-select>
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="是否开幅"
                                    field="scutchingState" :disabled="pageData.isDetails">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" v-model="dataForm.scutchingState" allowClear>
                                        <a-option value="2"> </a-option>
                                        <a-option value="0">不开幅</a-option>
                                        <a-option value="1">开幅</a-option>
                                    </a-select>
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="成分"
                                    field="ingredient" :disabled="pageData.isDetails">
                                    <a-input :class="{ bacClass: true }" v-model="dataForm.ingredient" />
                                </a-form-item>
                                <a-form-item :rules="[{ required: true, message: '加工单价必填' }]" :style="{ width: '325px' }"
                                    label-col-flex="100px" label="加工单价" :disabled="pageData.isDetails">
                                    <a-input-number :class="{ bacClass: true }" v-model="dataForm.machineUnit"
                                        class="input-demo" :min="0" :max="10000000000000" />
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="英文成分"
                                    field="englishIngredient" :disabled="pageData.isDetails">
                                    <a-input :class="{ bacClass: true }" v-model="dataForm.englishIngredient" />
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="产品日期"
                                    field="productTime" :disabled="pageData.isDetails">
                                    <a-date-picker  popup-container="html"  :class="{ bacClass: true }" style="width: 300px"
                                        v-model="dataForm.productTime" />
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="面料种类"
                                    field="fabricType" :disabled="pageData.isDetails">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" allow-clear allow-search
                                        @search="fabricTypeSelect" v-model="dataForm.fabricType" @focus="fabricTypeFocus">
                                        <a-option v-for="item in fabricTypeList" :value="item.fabricType">
                                            {{ item.fabricType }}
                                        </a-option>
                                    </a-select>
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="坯布组织"
                                    field="organization" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '坯布组织必选' }]">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" :loading="loading" v-model="dataForm.organization"
                                        :filter-option="false" allow-search allow-clear @focus="focusSel6"
                                        @search="handleSearch6">
                                        <a-option v-for="item in pageData.zuzhiList" :value="item.categoryName">{{
                                            item.categoryName }}
                                        </a-option>
                                    </a-select>
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="成品门幅"
                                    field="finishedLimit" :disabled="pageData.isDetails">
                                    <a-input :class="{ bacClass: true }" v-model="dataForm.finishedLimit" />
                                </a-form-item>

                             
                            </a-form>
                        </a-collapse-item>
                        <!-- 工艺信息 -->
                        <a-collapse-item header="工艺信息" :key="2">
                            <a-form style="padding-left: 40px" size="mini" ref="formRef1" layout="inline" :model="dataForm">
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="机型"
                                    field="machineType" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '机型必填' }]" :validate-trigger="['change', 'blur']">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" v-model="dataForm.machineType"
                                        @search="searchMachineTypeList" :filter-option="false" allow-search allow-clear
                                        @focus="focusMachineTypeList" @change="jixing" @blur="blurJx">
                                        <a-option v-for="item in pageData.machineTypeList" :value="item.typeName">
                                            {{ item.typeName }}
                                        </a-option>
                                    </a-select>
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="订单机型"
                                    field="orderMachineType" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '订单机型必填' }]" :validate-trigger="['change', 'blur']">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" v-model="dataForm.orderMachineType"
                                        @search="searchMachineTypeList" :filter-option="false" allow-search allow-clear
                                        @focus="focusMachineTypeList">
                                        <a-option v-for="item in pageData.machineTypeList" :value="item.typeName">
                                            {{ item.typeName }}
                                        </a-option>
                                    </a-select>
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="实际产量"
                                    field="activeOutput" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '实际产量必填' }]" :validate-trigger="['change', 'blur']">
                                    <a-input-number :class="{ bacClass: true }" v-model="dataForm.activeOutput"
                                        class="input-demo" :min="0" :max="10000000" />
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="理论产量"
                                    field="activeOutput" disabled :rules="[{ required: true, message: '理论产量必填' }]"
                                    :validate-trigger="['change', 'blur']">
                                    <a-input-number :class="{ bacClass: true }" v-model="dataForm.theoreticalYield"
                                        class="input-demo" :min="1" :max="10000000" />
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="理论单价"
                                    :disabled="pageData.isDetails">
                                    <a-input-number v-model="theoryPrice" :min="1" :max="10000000"
                                        :class="{ bacClass: true }" />
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="寸数"
                                    field="dimensionFigure" :rules="[{ required: true, message: '寸数必填' }]"
                                    :disabled="pageData.isDetails">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" v-model="dataForm.dimensionFigure"
                                        @search="searchNeedleCountList" :filter-option="false" allow-search allow-clear
                                        @change="changeNeedleCount" @focus="focusNeedleCountList">
                                        <a-option v-for="item in pageData.needleCountList" :value="item['model']">{{
                                            item['model'] }}
                                        </a-option>
                                    </a-select>
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="针数"
                                    field="needleCount" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '针数必填' }]">
                                    <a-input v-model="dataForm.needleCount" :class="{ bacClass: true }" disabled />
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="总针数"
                                    field="sumNeedleCount" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '总针数必填' }]">
                                    <a-input v-model="dataForm.sumNeedleCount" :class="{ bacClass: true }" disabled />
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="总路数"
                                    field="alwaysGoes" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '总路数必填' }]" :validate-trigger="['change', 'blur']">
                                    <a-input-number :class="{ bacClass: true }" v-model="dataForm.alwaysGoes"
                                        class="input-demo" :min="1" :max="10000000" />
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="颜色属性"
                                    field="colorAttribute" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '颜色属性必选' }]">
                                    <a-select popup-container="html"  :class="{ bacClass: true }" v-model="dataForm.colorAttribute"
                                        @search="searchColorAttribute" :filter-option="false" allow-search allow-clear
                                        @focus="focusColorAttribute">
                                        <a-option v-for="item in pageData.colorAttributeList"
                                            :value="item['colorattribute']">{{
                                                item['colorattribute'] }}
                                        </a-option>
                                    </a-select>
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="织机转速"
                                    field="loomRevolution" :disabled="pageData.isDetails"
                                    :rules="[{ required: true, message: '织机转速必选' }]">
                                    <a-input-number :class="{ bacClass: true }" v-model="dataForm.loomRevolution"
                                        class="input-demo" :min="1" :max="10000000" @change="getTheoreticalYield('')" />
                                </a-form-item>


                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="循环间距"
                                    field="circulationGap" :disabled="pageData.isDetails">
                                    <a-input :class="{ bacClass: true }" v-model="dataForm.circulationGap" />
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="胶管名称"
                                    field="rubberTube" :disabled="pageData.isDetails">

                                    <a-select popup-container="html"  :class="{ bacClass: true }" allow-clear v-model="dataForm.rubberTube"
                                        allow-search @focus="focusJgCx" @search="jgCx">
                                        <a-option v-for="item in jgCxArray">{{ item.rubberhoseName }}</a-option>
                                    </a-select>
                                </a-form-item>
                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="主推商品"
                                    field="popularizeCommodity" :disabled="pageData.isDetails">
                                    <a-input :class="{ bacClass: true }" placeholder=""
                                        v-model="dataForm.popularizeCommodity" />
                                </a-form-item>

                                <a-form-item :style="{ width: '325px' }" label-col-flex="100px" label="纱长"
                                    field="yarnLength" disabled>
                                    <a-input :class="{ bacClass: true }" placeholder="" v-model="dataForm.yarnLength" />
                                </a-form-item>
                                <a-form-item :style="{ width: '1372px' }" label-col-flex="100px" label="织造备注"
                                    field="weavingNote" :disabled="pageData.isDetails">
                                    <a-textarea :class="{ bacClass: true }" placeholder="" v-model="dataForm.weavingNote"
                                        :max-length="400" allow-clear show-word-limit />
                                </a-form-item>
                            </a-form>
                        </a-collapse-item>
                    </a-collapse>
                    <!-- 成分 -->
                    <a-tabs   :lazy-load="true" @change="gaibian">
                        <a-tab-pane key="1" title="纱支结构">
                            <a-space direction="vertical" fill>
                                <a-form :model="{}" layout="inline" :disabled="pageData.isDetails">
                                    <a-form-item v-if="!pageData.isDetails">
                                        <a-button @click="handleClick1" type="primary" size="mini"
                                            style="margin-right: 10px">选择原料
                                        </a-button>
                                        <a-button @click="delYl" type="primary" status="danger" size="mini">删除
                                        </a-button>
                                    </a-form-item>
                                </a-form>
                                <!-- 清空全选属性     :row-selection="{ showCheckedAll: true, width: 50 }" -->
                                <a-table :style="{ height: '400px' }" stripe :bordered="true" :columns="tableColumns1"
                                    size="mini" :row-selection="{ showCheckedAll: true, width: 50 }"
                                    v-model:selected-keys="selectedRowKeys" :loading="table.tableLoading"
                                    :data="ylTableList" :pagination="pagination" rowKey="yarnSource">
                                    <template #yarnSource="{ record }">
                                        <a-input :class="{ bacClass: true }" v-model="record.yarnSource"
                                            @change="changeYarnSource(record)" @input="tongbupaisha(record)"
                                            :disabled="pageData.isDetails" />
                                    </template>
                                    <template #yarnCode="{ record }">
                                        <a-input :class="{ bacClass: true }" v-model="record.yarnCode"
                                            :disabled="pageData.isDetails" />
                                    </template>
                                    <template #staple="{ record }">
                                        <a-input :class="{ bacClass: true }" v-model="record.staple"
                                            :disabled="pageData.isDetails" />
                                    </template>
                                    <template #stockNature="{ record }">
                                        <a-input :class="{ bacClass: true }" v-model="record.stockNature"
                                            :disabled="pageData.isDetails" />
                                    </template>
                                    <template #sYarnProperty="{ record }">
                                        <a-input :class="{ bacClass: true }" v-model="record.sYarnProperty"
                                            :disabled="pageData.isDetails" />
                                    </template>
                                    <template #yarnCount="{ record }">
                                        <a-input :class="{ bacClass: true }" v-model="record.yarnCount"
                                            :disabled="pageData.isDetails" />
                                    </template>
                                    <template #yarnType="{ record }">
                                        <a-input :class="{ bacClass: true }" v-model="record.yarnType"
                                            :disabled="pageData.isDetails" />
                                    </template>

                                    <template #danielCoefficient="{ record }">
                                        <a-input :class="{ bacClass: true }" v-model="record.danielCoefficient"
                                            @change="getTheoreticalYield(record)" :disabled="pageData.isDetails" />
                                    </template>
                                    <template #yarnCountProportion="{ record }">
                                        <a-input-number :class="{ bacClass: true }" v-model="record.yarnCountProportion"
                                            class="input-demo" style="background-color: rgb(255, 122, 117) !important;"
                                            @change="totalOnehundred(record, 'yarnCountProportion')"
                                            :disabled="pageData.isDetails" :min="0" :max="100" />
                                    </template>
                                    <template #actualYarn="{ record }">
                                        <a-input-number :class="{ bacClass: true }" v-model="record.actualYarn"
                                            class="input-demo" :disabled="pageData.isDetails" :min="0" :max="100"
                                            @change="totalOnehundred(record, 'actualYarn')"
                                            @blur="zhongAndYin(record.actualYarn, record)" />
                                    </template>
                                    <template #weavingDamage="{ record }">
                                        <a-input-number :class="{ bacClass: true }" v-model="record.weavingDamage"
                                            class="input-demo" style="background-color: rgb(255, 122, 117) !important;"
                                            :disabled="pageData.isDetails" />
                                    </template>
                                    <template #colorGroup="{ record }">
                                        <a-input :class="{ bacClass: true }" v-model="record.colorGroup"
                                            :disabled="pageData.isDetails" @change="isEng(record, record.colorGroup)" />
                                    </template>
                                    <template #circularSpacing="{ record }">
                                        <a-input-number :class="{ bacClass: true }" v-model="record.circularSpacing"
                                            :disabled="pageData.isDetails" />
                                    </template>
                                    <!-- <template #gapRatio="{ record }">
                                                          <a-input-number :class="{ 'bacClass': (!pageData.isDetails) }"
                                                              v-model="record.gapRatio" :disabled="pageData.isDetails"
                                                              :default-value="100" />
                                                      </template> -->
                                    <template #yarnLong="{ record }">
                                        <a-input-number :class="{ bacClass: true }" v-model="record.yarnLong"
                                            :disabled="pageData.isDetails"
                                            style="background-color: rgb(255, 122, 117) !important;"
                                            @change="getTheoreticalYield(record)" :precision="2" @blur="YarnLengthRule" />
                                    </template>
                                    <template #wayNum="{ record }">
                                        <a-input-number :class="{ bacClass: true }" v-model="record.wayNum"
                                            :disabled="pageData.isDetails"
                                            style="background-color: rgb(255, 122, 117) !important;"
                                            @change="getTheoreticalYield(record)" />
                                    </template>
                                    <template #yarnUnits="{ record }">
                                        <a-select popup-container="html"  :disabled="pageData.isDetails" :class="{ bacClass: true }"
                                            v-model="record.yarnUnits" @focus="getYarnUnitsList" allow-clear
                                            @change="getTheoreticalYield(record)"
                                            style="background-color: rgb(255, 122, 117) !important;">
                                            <a-option v-for="(item, index) in pageData.yarnUnitsList"
                                                :value="item['detailName']">{{
                                                    item['detailName'] }}</a-option>
                                        </a-select>
                                    </template>

                                    <template #colourNumber="{ record }">
                                        <a-select popup-container="html"  :disabled="pageData.isDetails" :class="{ bacClass: true }"
                                            v-model="record.colourNumber" :filter-option="false" allow-search allow-clear
                                            @focus="getcolornumber('色号')">
                                            <a-option @click="fuzhixiala({ val: '色号', item, record })"
                                                v-for="item in colornumberlist" :value="item['colourNumber']">{{
                                                    item['colorNumber'] }}
                                            </a-option>
                                        </a-select>
                                    </template>

                                    <template #colorAccording="{ record }">
                                        <!-- <a-select popup-container="html"  :disabled="pageData.isDetails" :class="{ 'bacClass': (!pageData.isDetails) }" v-model="record.colorAccording"
                                           :filter-option="false" allow-search allow-clear
                                          @focus="getcolornumber('色称')">
                                          <a-option @click="fuzhixiala({val:'色称',item})" v-for="item in colornamelist" :value="item['colorAccording']">{{
                                              item['colorName']
                                          }}
                                          </a-option>
                                      </a-select> -->

                                        <a-input :class="{ bacClass: true }" v-model="record.colorAccording" disabled />
                                    </template>
                                    <template #grade="{ record }">
                                        <a-select popup-container="html"  :disabled="pageData.isDetails" :class="{ bacClass: true }"
                                            v-model="record.grade" :filter-option="false" allow-search allow-clear
                                            @focus="getcolornumber('等级')">
                                            <a-option @click="fuzhixiala({ val: '等级', item })" v-for="item in dengjilist"
                                                :value="item['grade']">{{ item['levelName'] }}
                                            </a-option>
                                        </a-select>
                                    </template>
                                    <template #yujing="{ record }">
                                        <a-tag checkable color="green" :default-checked="true" v-if="record.jieguo == 1">否
                                        </a-tag>
                                        <a-tag checkable color="red" :default-checked="true" v-if="record.jieguo == 2">是
                                        </a-tag>
                                    </template>
                                </a-table>
                            </a-space>
                        </a-tab-pane>
                        <a-tab-pane key="2" title="排针">
                            <a-space v-if="!pageData.isDetails">
                                <a-select popup-container="html"  :class="{ bacClass: true }" style="width: 150px" @search="zzpzSelect"
                                    @focus="zzpzfocus" allow-search allow-clear v-model="zzpzid">
                                    <a-option v-for="item in zzpzListSelect" :value="item.id">{{ item.organizationName }}
                                    </a-option>
                                </a-select>
                                <a-button size="mini" @click="zzpzok" type="primary">选择组织排针</a-button>
                            </a-space>
                            <div style="height: 10px"></div>
                            <a-space direction="vertical" fill>
                                <a-space v-if="!pageData.isDetails">
                                    <span>设置排针列数</span><input v-model="colNumber" type="number"
                                        style="width: 100px; border: 1px solid black" min="1" max="999" />
                                    <a-button size="mini" type="primary" @click="addZhen">确定</a-button>
                                </a-space>
                                <div style="width: 100%; overflow: auto">
                                    <div style="white-space: nowrap">
                                        <span style="padding: 5px" v-if="dataForm.machineType != '单面机'">上排</span>
                                        <span style="padding: 5px" v-else>排针</span>
                                        <input @keyup="setNum(item)" v-for="(item, index) in zzpzdata" :key="index"
                                            style="width: 30px; border: 1px solid black; padding: 5px; text-align: center"
                                            :class="{ bacClass: true }" v-model="item.upBasin"
                                            :disabled="pageData.isDetails" />
                                    </div>
                                    <div style="white-space: nowrap" v-if="dataForm.machineType != '单面机'">
                                        <span style="padding: 5px" :style="{
                                            'padding-right': dataForm.machineType == '螺纹机' ? '35px' : '5px',
                                        }">下排</span>

                                        <input @keyup="setNum1(item)" v-for="(item, index) in zzpzdata" :key="index"
                                            :class="{ bacClass: true }"
                                            style="width: 30px; border: 1px solid black; padding: 5px; text-align: center"
                                            v-model="item.belowBasin" :disabled="pageData.isDetails" />
                                    </div>
                                </div>
                            </a-space>

                            <a-divider />
                            <div>
                                <a-select popup-container="html"  :class="{ bacClass: true }" size="mini" v-model="ckpzid" @search="ckpzSelect"
                                    @focus="ckpzfocus" allow-search allow-clear :style="{ width: '150px' }"
                                    :disabled="pageData.isDetails">
                                    <a-option v-for="item in ckpzSelectList" :key="item.id" :value="item.id">
                                        {{ item.cmdName }}
                                    </a-option>
                                </a-select>
                                <a-button @click="ckpzadd" status="success" size="mini" v-if="!pageData.isDetails">选择裁口排针
                                </a-button>
                                <div style="display: flex; align-items: center">
                                    <div style="width: 50%">
                                        <span>裁口排针</span>
                                        <a-textarea :class="{ bacClass: true }" v-model="ckpzobj.pinHeader"
                                            :disabled="pageData.isDetails">
                                        </a-textarea>
                                    </div>
                                    <div style="width: 50%">
                                        <span>纱线排列</span>
                                        <a-textarea :class="{ bacClass: true }" v-model="ckpzobj.arrangement"
                                            :disabled="pageData.isDetails">
                                        </a-textarea>
                                    </div>
                                </div>
                            </div>
                        </a-tab-pane>
                        <a-tab-pane key="3" title="排三角">
                            <a-space v-if="!pageData.isDetails">
                                <div>
                                    <a-space>
                                        <a-select popup-container="html"  :class="{ bacClass: !pageData.isDetails }" allow-search placeholder=""
                                            v-model="sjid" @search="sjSelect" allow-clear :style="{ width: '200px' }"
                                            @focus="focusSj" @blur="selectPsj(2)">
                                            <a-option v-for="item in sjSelectList" :value="item.id" :key="item.id">
                                                {{ item.atName }}
                                            </a-option>
                                        </a-select>
                                        <a-button @click="sjOk">选择排三角</a-button>
                                        <a-select popup-container="html"  :class="{ bacClass: !pageData.isDetails }" @search="psjpblistSelect"
                                            @focus="psjpblistSelect" placeholder="" allow-search allow-clear
                                            :style="{ width: '200px' }" v-model="psjpb">
                                            <a-option v-for="item in psjpblist" :value="item.id">{{ item.greyCode }}
                                            </a-option>
                                        </a-select>
                                        <a-button size="mini" type="outline" @click="psjpbOk">现有坯布导入排三角</a-button>
                                    </a-space>
                                </div>
                                <a-form layout="inline" :model="dataForm">
                                    <a-form-item label="机型">
                                        <!-- <a-select popup-container="html"  :class="{ 'bacClass': (!pageData.isDetails) }" v-model="dataForm.models">
                                              <a-option value="1">单面机</a-option>
                                              <a-option value="2">双面机</a-option>
                                          </a-select> -->
                                        <a-select popup-container="html"  :disabled="true" :class="{ bacClass: true }"
                                            v-model="dataForm.machineType" @search="searchMachineTypeList"
                                            :filter-option="false" allow-search allow-clear @focus="focusMachineTypeList"
                                            @change="jixing">
                                            <a-option v-for="item in pageData.machineTypeList" :value="item.typeName">
                                                {{ item.typeName }}
                                            </a-option>
                                        </a-select>
                                    </a-form-item>
                                    <a-form-item>
                                        <!-- 非单面机 -->
                                        <a-radio-group v-model="tagValue">
                                            <a-radio v-for="item in pageData.tags" :value="item.id">
                                                {{ item.val }}
                                            </a-radio>
                                        </a-radio-group>
                                    </a-form-item>
                                </a-form>
                            </a-space>
                            <!--                    <a-form ref="formRefsj" layout="inline" :model="sjdata">-->
                            <!--                        <a-form-item label="编号" field="atCode"-->
                            <!--                            :rules="[{ required: true, message: '编号必填' }, { match: /^[a-zA-Z0-9]{1,}$/g, message: '编号必须是数字和字母' }]"-->
                            <!--                            :validate-trigger="['change', 'blur']">-->
                            <!--                            <a-input :class="{'bacClass':(!pageData.isDetails)}" disabled v-model="sjdata.atCode">-->
                            <!--                            </a-input>-->
                            <!--                        </a-form-item>-->
                            <!--                        <a-form-item label="名称" field="atName" :rules="[{ required: true, message: '名称必填' }]"-->
                            <!--                            :validate-trigger="['change', 'blur']">-->
                            <!--                            <a-input :class="{'bacClass':(!pageData.isDetails)}" disabled v-model="sjdata.atName"></a-input>-->
                            <!--                        </a-form-item>-->
                            <!--                        <a-form-item label="备注" field="remark">-->
                            <!--                            <a-input :class="{'bacClass':(!pageData.isDetails)}" v-model="sjdata.remark"></a-input>-->
                            <!--                        </a-form-item>-->

                            <!--                    </a-form>-->
                            <div style="height: 20px"></div>
                            <a-space v-if="sjdata.sj.length && !pageData.isDetails">
                                <a-input-number :class="{ bacClass: !pageData.isDetails }" :min="1" :max="999" size="mini"
                                    @change="xunhuan('实开')" @blur="YarnLengthRule" v-model="numb.col"></a-input-number>
                                <!-- <a-button size="mini" type="primary" status="success" @click="addCol">
                                      设置循环路数
                                  </a-button> -->
                                <a-button size="mini" type="primary" status="success" @click="xuanranpaisha">
                                    设置循环路数
                                </a-button>
                                循环次数:
                                <a-input-number :class="{ bacClass: !pageData.isDetails }" :min="1" :max="999" size="mini"
                                    v-model="xuanhuancihu" @change="xunhuan('循环')"></a-input-number>
                                实开路数:
                                <a-input-number :class="{ bacClass: !pageData.isDetails }" :min="1" :max="999" size="mini"
                                    v-model="shikaishu" :disabled="true"></a-input-number>
                                针叶型号:
                                <a-input :class="{ bacClass: !pageData.isDetails }" v-model="dataForm.needleType" />
                            </a-space>

                            <div v-for="(item, index) in sjdata.sj as any"
                                style="text-align: center; margin: 20px auto; width: 100%; overflow-x: auto">
                                <div style="
                                                  text-align: center;
                                                  color: #165dff;
                                                  font-size: 16px;
                                                  background-color: aliceblue;
                                                  border-bottom: 0.5px solid #ccc;
                                                ">
                                    {{ item.type }}
                                </div>

                                <div class="thead" style="background-color: aliceblue"
                                    v-if="item.typeData[0].needleList != undefined">
                                    <div class="th" style="width: 50px">序号</div>
                                    <div class="th" style="width: 150px">用针</div>
                                    <div class="th" style="width: 40px" v-for="i2 in item.typeData[0].needleList"
                                        :key="i2.way">
                                        {{ i2.way }}
                                    </div>
                                </div>
                                <div class="tbody" :style="{ position: 'relative', top: biaoji != 0 ? '-5px' : '' }"
                                    v-for="(i1, biaoji) in item.typeData">
                                    <div class="td" style="width: 50px">{{ i1.serialNumber }}</div>
                                    <div class="td" style="width: 150px">
                                        <!-- <a-input  :class="{ bacClass:true }" v-model="i1.needleName"
                                              :disabled="pageData.isDetails"></a-input> -->

                                        <a-tooltip :content="i1.needleName" v-if="i1.needleName != ''">
                                            <a-select popup-container="html"  :disabled="pageData.isDetails"
                                                @focus="getwuliao({ materialName: '', auditState: 1 })" @search="getwuliao"
                                                :class="{ bacClass: true }" v-model="i1.needleName" allow-search>
                                                <a-option v-for="item in wuliaoname" :value="item.materialName">{{
                                                    item.materialName }}
                                                </a-option>
                                            </a-select>
                                        </a-tooltip>
                                        <a-select popup-container="html"  :disabled="pageData.isDetails"
                                            @focus="getwuliao({ materialName: '', auditState: 1 })" @search="getwuliao"
                                            v-if="i1.needleName == ''" :class="{ bacClass: true }" v-model="i1.needleName"
                                            allow-search>
                                            <a-option v-for="item in wuliaoname" :value="item.materialName">{{
                                                item.materialName }}
                                            </a-option>
                                        </a-select>
                                    </div>
                                    <div class="td" style="
                                                    height: 34px;
                                                    width: 40px;
                                                    vertical-align: middle;
                                                    border: 1px solid gray;
                                                  " v-for="i2 in i1.needleList">
                                        <div style="width: 100%; height: 100%" class="gesture" @click="setSJValue(i2, item)"
                                            v-if="!pageData.isDetails">{{ pageData.tags.filter((o) => o.id ===
                                                i2.needle)[0]?.val }}
                                        </div>
                                        <div style="width: 100%; height: 100%" v-if="pageData.isDetails">{{
                                            pageData.tags.filter((o) => o.id
                                                === i2.needle)[0]?.val }}
                                        </div>
                                    </div>
                                </div>
                                <div style="height: 20px"></div>
                                <a-space fill v-if="!pageData.isDetails">
                                    <a-input-number :class="{ bacClass: !pageData.isDetails }" :min="1" :max="999"
                                        v-model="numb.row[index]" size="mini"></a-input-number>
                                    <a-button @click="addRow(item)" type="primary" size="mini">设置用针 </a-button>
                                </a-space>
                                <div style="height: 20px"></div>
                                <div style="border: 1px solid #ccc"></div>
                            </div>
                            <!-- 排纱 numb.col列 ylTableList行+1-->
                            <a-button type="primary" size="mini" @click="handleClick" v-if="!pageData.isDetails">批量修改
                            </a-button>
                            <div class="tbody" style="margin-top: 10px; overflow: auto">
                                <div style="
                                                  text-align: center;
                                                  color: #165dff;
                                                  font-size: 16px;
                                                  background-color: aliceblue;
                                                  border-bottom: 0.5px solid #ccc;
                                                ">
                                    排纱
                                </div>
                                <div class="trow" style="background-color: aliceblue">
                                    <div style="
                                                    height: 30px;
                                                    display: inline-block;
                                                    width: 82px;
                                                    vertical-align: top;
                                                    box-sizing: border-box;
                                                  ">
                                    </div>
                                    <div style="
                                                    height: 30px;
                                                    display: inline-block;
                                                    width: 82px;
                                                    vertical-align: top;
                                                    box-sizing: border-box;
                                                  ">
                                    </div>

                                    <div v-for="(item, index) in xhCol" style="
                                                    height: 30px;
                                                    display: inline-block;
                                                    vertical-align: top;
                                                    width: 80px;
                                                    line-height: 30px;
                                                  ">
                                        <input type="checkbox" :value="index" @change="changeXh($event, index)"
                                            :class="{ bacClass: true }" class="inputCheck gesture" v-if="index != 0"
                                            :disabled="pageData.isDetails" />
                                        {{ index == 0 ? '序号' : index }}
                                    </div>
                                </div>
                                <div class="trow" v-for="(item, index) in psList">
                                    <div style="border: 1px solid #ccc; height: 30px; box-sizing: border-box"
                                        v-for="(item1, index1) in item">
                                        <input v-model="item1.val" v-if="!(
                                            (index > 0 && (index1 == 0 || index1 == 1 || index1 == 2)) ||
                                            (index == 0 && index1 === 2)
                                        )
                                            " style="width: 80px; vertical-align: top; height: 100%; text-align: center" @blur="getWayNum"
                                            :class="{ active: index1 == 0 || index1 == 1, bacClass: true }"
                                            :disabled="pageData.isDetails" />
                                        <select :class="{ bacClass: true }" v-model="item1.val"
                                            v-if="index > 0 && index1 == 2"
                                            style="width: 80px; vertical-align: top; height: 100%; text-align: center"
                                            :disabled="pageData.isDetails" @focus="focusPs" @change="YarnLengthRule">
                                            <option v-for="(item2, index2) in pageData.psDataList"
                                                :value="item2['detailName']">
                                                {{ item2['detailName'] }}
                                            </option>
                                        </select>

                                        <a-tooltip v-if="index > 0 && item1.val != '纱长(cm)'" :content="item1.text">
                                            <div v-if="(index > 0 && (index1 == 0 || index1 == 1)) ||
                                                (index == 0 && index1 === 2)
                                                " style="width: 80px; vertical-align: top; height: 100%; text-align: center"
                                                :class="{ active: index1 == 0 || index1 == 1, bacClass: true }">{{
                                                    item1.val }}
                                                <div v-if="item1.val == '' && item1.text != ''">&nbsp;&nbsp;</div>
                                            </div>
                                        </a-tooltip>

                                        <div v-if="(((index > 0 && (index1 == 0 || index1 == 1)) ||
                                            (index == 0 && index1 === 2)) &&
                                            index == 0) ||
                                            item1.val == '纱长(cm)'
                                            " style="width: 80px; vertical-align: top; height: 100%; text-align: center"
                                            :class="{ active: index1 == 0 || index1 == 1, bacClass: true }">{{
                                                item1.val }}
                                        </div>

                                        <!-- =============================== -->

                                        <!-- v-if="index>0&&item1.val!='纱长(cm)'" -->
                                    </div>
                                    <!-- <div style="width:100px;">
                                                  <a-input></a-input>
                                              </div>
                                              <div style="width:100px;">
                                                  <a-input></a-input>
                                              </div>
                                              <div style="width:30px" v-for="item in sjdata.sj[0].typeData[0].needleList">
                                                  <input type="text" style="width:30px;height: 30px;border: 1px solid black;" />
                                              </div>
                                          </div>
                                          <div class="trow" v-for="itemn in ewsj">
                                              <div style="width:100px;text-align:center">
                                                  纱长（cm）
                                              </div>
                                              <div style="width:100px;text-align:center">
                                                  {{ itemn.staple }}
                                              </div>
                                              <div style="width:30px" v-for="item in itemn">
                                                  <input type="text" v-model="item.info"
                                                      style="width:30px;height: 30px;border: 1px solid black;" />
                                              </div> -->
                                </div>
                            </div>
                        </a-tab-pane>

                        <a-tab-pane key="6" title="关联商品">
                            <a-space style="margin-bottom: 10px" v-if="!pageData.isDetails">
                                <a-select popup-container="html"  :class="{ bacClass: !pageData.isDetails }" size="mini" @search="spSelect"
                                    v-model="sp.id" allow-clear allow-search @focus="focusSp" :style="{ width: '150px' }">
                                    <a-option v-for="item in spSelectList" :value="item.id">{{ item['commodityCode'] }}
                                    </a-option>
                                </a-select>
                                <a-button type="primary" size="mini" @click="addSpRow">添加</a-button>
                                <a-button type="primary" status="danger" size="mini" @click="delSpRow">删除</a-button>
                            </a-space>
                            <a-table stripe :bordered="true" :columns="sptablecol" size="mini"
                                :row-selection="{ showCheckedAll: true, width: 50 }"
                                v-model:selected-keys="selectedRowKeysSp" :loading="table.tableLoading"
                                :data="pageData.spRowList" :pagination="false" :rowKey="rowKey">
                                <template #isban="{ record }">
                                    <!-- <a-switch v-model="record.commodityState" checked-color="#F53F3F" unchecked-color="#14C9C9" unchecked-value="0" checked-value="1" >
                                          <template #checked>
                                          禁用
                                      </template>
                                  <template #unchecked>
                                        启用
                                        </template>
                                          </a-switch> -->
                                    <a-checkbox @change="isBan(record)" :default-checked="record.isban"
                                        v-model="record.isban">
                                        {{ record.isban == true ? '是' : '否' }}
                                    </a-checkbox>
                                </template>
                            </a-table>
                        </a-tab-pane>
                        <a-tab-pane key="7" title="排三角(旧)">
                            <!-- <a-input :class="{'bacClass':(!pageData.isDetails)}" placeholder="" v-model="dataForm.weavingNote" /> -->
                            排三角:
                            <a-textarea :disabled="pageData.isDetails" style="margin-top: 10px" :class="{ bacClass: true }"
                                placeholder="" v-model="crossMemo" :max-length="400" allow-clear show-word-limit />
                        </a-tab-pane>
                    </a-tabs>
                </el-scrollbar>
            </div>
        </a-drawer>

        <a-modal v-model:visible="visible" title="批量修改排纱" @cancel="handleCancel" @ok="handleBeforeOk">
            <a-form :model="moreEdit">
                <a-form-item v-for="(val, index) in psEditList" :field="val" :label="val">
                    <a-input :class="{ bacClass: !pageData.isDetails }" v-model="moreEdit[val + '_' + index]" />
                </a-form-item>
            </a-form>
        </a-modal>

        <a-modal v-model:visible="visible1" title="添加原料" @cancel="handleCancel1" @ok="addYl" ok-text="添加" :width="1000"
            draggable>
            <a-button type="primary" @click="cxYlList" size="mini">查询</a-button>
            <a-form style="width: 100% !important" size="mini" :model="ylData" layout="inline">
                <a-form-item label="原料编号">
                    <a-input :class="{ bacClass: true }" v-model="ylData.rawmaterialCode" />
                    <!-- <a-select popup-container="html"  :class="{ bacClass: !pageData.isDetails }" :style="{ width: '200px' }" :loading="loading"
              @search="handleSearchYl" v-model="ylData.rawmaterialCode" :filter-option="false" allow-clear allow-search
              @focus="focusSelYl('rawmaterialCode')">
              <a-option v-for="item in pageData.rawmaterialCodeList" :value="item.rawmaterialCode">{{ item.rawmaterialCode
              }}
              </a-option>
            </a-select> -->
                </a-form-item>
                <a-form-item label="原料名称">
                    <a-input :class="{ bacClass: true }" v-model="ylData.materialsName" />
                    <!-- <a-select popup-container="html"  :class="{ bacClass: !pageData.isDetails }" :loading="loading" :style="{ width: '200px' }"
              @search="handleSearchYl" v-model="ylData.materialsName" :filter-option="false" allow-clear allow-search
              @focus="focusSelYl('materialsName')">
              <a-option v-for="item in pageData.materialsNameList" :value="item.materialsName">{{ item.materialsName }}
              </a-option>
            </a-select> -->
                </a-form-item>

                <a-form-item label="纱支" style="padding-left: 28px">
                    <a-input :class="{ bacClass: true }" v-model="ylData.yarnCount" />
                    <!-- <a-select popup-container="html"  :class="{ bacClass: true }" :loading="loading" :style="{ width: '200px' }" @search="handleSearchYl"
              v-model="ylData.yarnCount" :filter-option="false" allow-search allow-clear @focus="focusSelYl('yarnCount')">
              <a-option v-for="item in pageData.yarnCountList" :value="item.yarnCount">{{ item.yarnCount }}
              </a-option>
            </a-select> -->
                </a-form-item>
                <a-form-item :style="{ width: '200px' }" label-col-flex="70px" label="是否本集团" field="processType">
                    <a-select popup-container="html"  :style="{ width: '180px' }" :class="{ bacClass: true }" v-model="ylData.processType">
                        <a-option :value="0">本集团</a-option>
                        <a-option :value="1">外加工</a-option>
                    </a-select>
                </a-form-item>
            </a-form>
            <a-table stripe :bordered="true" :columns="ylColumns" size="mini"
                :row-selection="{ showCheckedAll: true, width: 50 }" v-model:selected-keys="selectedRowKeysAddYl"
                :loading="table.tableLoading" :data="pageData.ylRowList" :pagination="false" :rowKey="rowKey">
                <template #processType="{ record }">
                    <div>{{ record.processType }}</div>
                </template>
            </a-table>
        </a-modal>
    </pageTabelLayout>
</template>
  
  
<script lang="ts">
import { post, get } from '@/api/http'
import { useTable, useRowKey, useTableColumn, usePagination, useRowSelection } from '@/hooks/table'
import emitter from '@/hooks/useEventBus'
import { ref, reactive, onMounted, toRefs, watch, toRaw } from 'vue'
import Toolbar from '@/components/Toolbar.vue'
import { Button, Form, Message, Modal } from '@arco-design/web-vue'
import { FormInstance } from '@arco-design/web-vue/es/form'
import { log } from 'echarts/types/src/util/log'

import { localeText } from '@/api/aggridZw'
import { pagingList } from '@/api/paging'
import { indexOf } from 'lodash'
import usePermission from '@/store/modules/permission'
import { simplifyMessages } from '@/api/messageSimplification'
interface Firm {
    name: string
    id: number
}

interface RawMaterialsList {
    orderMachineType: any
    circulationGap: any
    exploitCode: string | undefined
    shipperUnits: string | undefined
    activeOutput: number | undefined
    clothKindOfName: string | undefined
    loomRevolution: number | undefined
    yarnCountCode: string | undefined
    sebificDuctName: string | undefined
    id: number | undefined | string
    starts: string | undefined
    yarnCountCategory: string | undefined
    playingCards: string | undefined
    updateName: string | undefined
    greyCode: string | undefined
    inventoryLowerLimit: string | undefined
    beadJuggle: string | undefined
    knittingNeedleType: string | undefined
    productKind: string | undefined
    unit: string | undefined
    versions: string | undefined
    associatedGoods: string | undefined
    dimensionFigure: any
    grade: string | undefined
    createName: string | undefined
    colorAccording: string | undefined
    needleType: string | undefined
    englishName: string | undefined
    weaverPrice: number
    machineUnit: any
    weavingDamage: any
    actualYarn: any
    yarnCountIngredient: string | undefined
    remark: string | undefined
    productTime: any
    measuredYarnCount: string | undefined
    fabricType: string | undefined
    alwaysGoes: number | undefined
    needleCount: any
    feature: string | undefined
    mercery: string | undefined
    sumNeedleCount: any
    colorGroup: any
    machineType: string | undefined
    deleteState: number | undefined
    outsideProcessingClient: string | undefined
    ingredient: string | undefined
    englishIngredient: string | undefined
    weavingNote: string | undefined
    chineseIngredient: string | undefined
    yarnSource: string | undefined
    staple: string | undefined
    yarnKind: string | undefined
    stockNature: string | undefined
    sYarnProperty: string | undefined
    danielCoefficient: string | undefined
    yarnCountProportion: any
    inventoryDivisionMachine: string | undefined
    colorAttribute: string | undefined
    theoryCapacity: number | undefined
    updateTime: string | undefined
    grayFabricName: string | undefined
    drawnNeedleState: number | undefined | string
    scutchingState: any
    putOnRecordsCode: string | undefined
    yarnCountName: string | undefined
    createTime: string | undefined
    organization: string | undefined
    commodityState: string | undefined
    category: string | undefined
    inventoryUpperLimit: string | undefined
    popularizeCommodity: string | undefined
    finishedLimit: string | undefined
    finishedWeight: string | undefined
    colourNumber: number | undefined
    models: string | undefined
    processType: number | undefined
    rubberTube: any
    checkUnits: any
    perchPrice: any
    perchUnits: any
    yarnLength: any
    theoreticalYield: any
}

export default {
    name: 'EmbroideryList',
    setup() {
        emitter.on('noPaiCanRowIdisXq', (record: any) => {
            console.log(record)
            nextTick(()=>{
                editHandler(record, 2)
            })
        })
        const total = ref(0)
        const page = ref(1)
        const size = ref(10)

        function PageSize(val: any) {
            page.value = val
            doRefresh()
        }

        function change1(val: any) {
            size.value = val
            doRefresh()
        }

        const headerShow = ref<boolean>(true)
        const ylList = ref<any[]>()

        const pageData = reactive<{
            gcList: Firm[]
            showAdd: boolean
            pageLoading: boolean
            sideTitle: string
            dropDownData: any
            dropDownData1: any
            dropDownData2: any
            dropDownData3: any
            dropDownData4: any
            codeList: []
            nameList: []
            nameList1: []
            ggList: []
            flList: []
            needleCountList: any[]
            machineTypeList: any[]
            colorAttributeList: any[]
            unitList: any[]
            spRowList: any[]
            rHeight: number | undefined
            zuzhiList: any[]
            ylRowList: any[]
            materialsName: any
            rawmaterialCode: any
            yarnCount: any
            materialsNameList: any[]
            rawmaterialCodeList: any[]
            yarnCountList: any[]
            zhong: any
            yin: any
            isDetails: boolean
            cfPjList: any[]
            ylCfIdList: any[]
            psDataList: any[]
            tags: any[]
            wuliaoname: any[]
            isEdit: boolean
            btnList1: any[]
            btnList2: any[]
            isEdit1: boolean
            isEdit2: boolean
            isInfo1: boolean
            isInfo2: boolean
            yarnUnitsList: any[]
            wayList: any[]
        }>({
            isEdit: false,
            btnList1: [],
            btnList2: [],
            isEdit1: false,
            isEdit2: false,
            isInfo1: false,
            isInfo2: false,
            gcList: [],
            showAdd: false,
            pageLoading: false,
            sideTitle: '新增坯布',
            dropDownData: '',
            dropDownData1: '',
            dropDownData2: '',
            dropDownData3: '',
            dropDownData4: '',
            codeList: [],
            nameList: [],
            nameList1: [],
            ggList: [],
            flList: [],
            needleCountList: [],
            machineTypeList: [],
            colorAttributeList: [],
            unitList: [],
            spRowList: [],
            rHeight: 0,
            zuzhiList: [],
            ylRowList: [],
            materialsName: '',
            rawmaterialCode: '',
            yarnCount: '',
            materialsNameList: [],
            rawmaterialCodeList: [],
            yarnCountList: [],
            zhong: '',
            yin: '',
            isDetails: false,
            cfPjList: [],
            ylCfIdList: [],
            psDataList: [],
            tags: [
                { id: '1', val: '̶' },
                { id: '2', val: 'Ո' },
                { id: '3', val: 'Ս' },
                { id: '4', val: 'Ʌ' },
                {
                    id: '5',
                    val: 'V',
                },
            ],
            wuliaoname: [] as any,
            yarnUnitsList: [],
            wayList: []
        })
        // 成分原料
        let ylId = ref<any>()
        const ylTableList = ref<any[]>([])
        let allDataList: any[] = []
        const szFinalList = [
            'A',
            'B',
            'C',
            'D',
            'E',
            'F',
            'G',
            'H',
            'I',
            'J',
            'K',
            'L',
            'M',
            'N',
            'O',
            'P',
            'Q',
            'R',
            'S',
            'T',
            'U',
            'V',
            'W',
            'X',
            'Y',
            'Z',
        ]
        const addYl = () => {
            if (selectedRowKeysAddYl.value.length == 0) {
                Message.warning('请选择原料信息！')
                return
            }
            visible1.value = false
            ylList.value = pageData.ylRowList.filter(function (o: any) {
                return selectedRowKeysAddYl.value.includes(o['id'])
            })
            for (let index = 0; index < ylList.value.length; index++) {
                pageData.ylCfIdList.push(ylList.value[index]['id'])
            }
            for (let j = 0; j < selectedRowKeysAddYl.value.length; j++) {
                const yl = ylList.value?.filter((o) => {
                    return o.id === selectedRowKeysAddYl.value[j]
                })
                // // 判断原料是否被选择过
                // const temp = ylTableList.value.filter((o) => {
                //   return o.staple === yl[0].staple
                // })
                // if (temp.length > 0) {
                //   Message.warning('原料名称:' + yl[0].staple + '已有选择！')
                //   return
                // }
            }
            for (let j = 0; j < selectedRowKeysAddYl.value.length; j++) {
                const yl = ylList.value?.filter((o) => {
                    return o.id === selectedRowKeysAddYl.value[j]
                })
                // 定义数组 装纱支代码
                const szList: any = []
                // 判断原料是否被选择过
                const temp = ylTableList.value.filter((o) => {
                    szList.push(o['yarnSource'])
                    return o.staple === yl[0].staple
                })
                var yarnSource = ''

                // 原料类别为氨纶的，固定为L
                if (yl != undefined) {
                    if (yl.length > 0) {
                        if (yl[0].yarnKind == '氨纶') {
                            yarnSource = 'L'
                        } else {
                            // 由A到Z自增赋值纱支代码
                            for (var i = 0; i < szFinalList.length; i++) {
                                let tempSourse = szFinalList[i]
                                if (!szList.includes(tempSourse)) {
                                    yarnSource = tempSourse
                                    break
                                }
                            }
                        }
                        yl[0]['yarnSource'] = yarnSource
                        yl[0]['ylId'] = yl[0]['id']
                        yl[0]['id'] = undefined
                        // yl[0]['yarnSource'] = yarnSource;
                        ylTableList.value.push(yl[0])
                    }
                }
                getWayNum()
            }

            pageData.ylRowList = []
            selectedRowKeysAddYl.value = []
            ylData.value = {
                materialsName: '',
                rawmaterialCode: '',
                yarnCount: '',
                auditState: 1,
                processType: 0
            }
            dataForm.grayFabricName = ''
            getGrayFabricName()
            ylTableList.value.forEach(function (o: any) {
                //排纱 数据
                RendPs(1)
                //悬浮提示
                // huoquyuanliaomingcheng(o);
            })
        }

        //悬浮提示
        const huoquyuanliaomingcheng = (val: any) => {
            //  psList.value.forEach((a:any) => {
            //     if(val.yarnSource==a[1].val){
            //         a[1]["text"]=val.staple
            //     }
            //  });
        }

        //判断用户勾选了多少条原料信息然后拼接成分和英文成分
        function zhongAndYin(scSb: any, record: any) {
            //基础信息 的中文成分和英文成分  中（中文成分加纱支比）英（英文成分加纱支比）
            // 取成分
            pageData.zhong = ''
            pageData.yin = ''

            if (pageData.ylCfIdList.length > 0) {
                post({
                    url: 'product/RawmaterialComponent/getList',
                    data: { infoId: '' },
                }).then(({ code, data }: any) => {
                    if (code === 200) {
                        pageData.cfPjList = data.filter(function (o: any) {
                            return pageData.ylCfIdList.includes(o['infoId'])
                        })

                        let list: any = []
                        let ob = {}
                        pageData.cfPjList.forEach(function (o: any) {
                            if (ob[o['infoId']] == undefined) {
                                ob[o['infoId']] = {}
                                ob[o['infoId']]['ingredient'] = o['ingredient']
                                ob[o['infoId']]['ingredientEnglish'] = o['ingredientEnglish']
                            } else {
                                ob[o['infoId']]['ingredient'] =
                                    ob[o['infoId']]['ingredient'] + '/' + o['ingredient']
                                ob[o['infoId']]['ingredientEnglish'] =
                                    ob[o['infoId']]['ingredientEnglish'] + '/' + o['ingredientEnglish']
                            }
                        })

                        for (let key in ob) {
                            ob[key]['ylId'] = key
                            list.push(ob[key])
                        }
                        list.forEach(function (o: any) {
                            ylTableList.value.forEach(function (o1: any) {
                                if (o1['ylId'] == o['ylId']) {
                                    if (
                                        o['ingredient'] != undefined &&
                                        o['ingredient'] != '' &&
                                        o1['actualYarn'] != undefined &&
                                        o1['actualYarn'] != ''
                                    ) {
                                        if (pageData.zhong == '') {
                                            pageData.zhong = o1['actualYarn'] + '%' + o['ingredient']
                                        } else {
                                            pageData.zhong += '+' + o1['actualYarn'] + '%' + o['ingredient']
                                        }
                                    } else {
                                        pageData.zhong += ''
                                    }
                                    if (
                                        o['ingredientEnglish'] != undefined &&
                                        o['ingredientEnglish'] != '' &&
                                        o1['actualYarn'] != undefined &&
                                        o1['actualYarn'] != ''
                                    ) {
                                        if (pageData.yin == '') {
                                            pageData.yin = o1['actualYarn'] + '%' + o['ingredientEnglish']
                                        } else {
                                            pageData.yin += '+' + o1['actualYarn'] + '%' + o['ingredientEnglish']
                                        }
                                    } else {
                                        pageData.yin += ''
                                    }
                                }
                            })
                        })
                        dataForm.ingredient = pageData.zhong
                        dataForm.englishIngredient = pageData.yin
                    }
                })
            }
        }

        // 构造坯布名称
        function getGrayFabricName() {
            dataForm.grayFabricName = ''
            if (dataForm.mercery != '' && ylTableList.value.length > 0) {
                ylTableList.value.forEach(function (o) {
                    if (dataForm.grayFabricName == '') {
                        dataForm.grayFabricName += o.staple
                    } else {
                        dataForm.grayFabricName += '+' + o.staple
                    }
                })
                dataForm.grayFabricName += '+' + (dataForm.mercery == null ? '' : dataForm.mercery)
            }
            // // 构造坯布名称
            // ylTableList.value.forEach(function (o) {
            //     if (dataForm.grayFabricName == "") {
            //         dataForm.grayFabricName += o.staple
            //     } else {
            //         dataForm.grayFabricName += ("+" + o.staple)
            //     }
            // })
            // if (dataForm.grayFabricName == "") {
            //     dataForm.grayFabricName += (dataForm.mercery == null ? "" : dataForm.mercery)
            // } else {
            //     dataForm.grayFabricName += ("+" + (dataForm.mercery == null ? "" : dataForm.mercery))
            // }
        }

        //渲染排纱方法
        function RendPs(num: any) {
            // debugger;
            if (num != 1) {
                psList.value = []
            }
            if (psList.value.length == 0) {
                let list = []

                for (let j = 0; j < numb.col + 3; j++) {
                    list[j] = { val: '' }
                    if (j == 2) {
                        list[j] = { val: '排纱' }
                    }
                }
                psList.value.push(list)
                for (let index = 0; index < ylTableList.value.length; index++) {
                    let lis = []
                    // for (let j = 0; j < numb.col + 3; j++) {
                    //     lis[j] = { val: "" }
                    //     if (j == 0) {
                    //         lis[j] = { val: '纱长(cm)' }
                    //     }
                    //     if (j == 1) {
                    //         lis[j] = { val: ylTableList.value[index]['yarnSource'] }
                    //     }
                    // }

                    for (let j = 0; j < numb.col + 3; j++) {
                        lis[j] = { val: '' }
                        if (j == 0) {
                            lis[j] = { val: '纱长(cm)' }
                        }
                        if (j == 1) {
                            lis[j] = { val: ylTableList.value[index]['yarnSource'] }
                        }
                    }
                    psList.value.push(lis)
                }
            } else {
                var list = []
                // for (let j = 0; j < numb.col + 3; j++) {
                //     list[j] = { val: "" }
                //     if (j == 0) {
                //         list[j] = { val: '纱长(cm)' }
                //     }
                //     if (j == 1) {
                //         list[j] = { val: ylTableList.value[psList.value.length - 1]['yarnSource'] }
                //     }
                // }

                for (let j = 0; j < numb.col + 3; j++) {
                    list[j] = { val: '' }
                    if (j == 0) {
                        list[j] = { val: '纱长(cm)' }
                    }
                    if (j == 1) {
                        list[j] = { val: ylTableList.value[psList.value.length - 1]['yarnSource'] }
                    }
                }
                psList.value.push(list)
            }
        }

        const changeYarnSource = (record: any) => {
            if (record.yarnKind == '氨纶') {
                Message.warning('原料类别为:' + record.yarnKind + ',不可修改纱支代码！')
                record.yarnSource = 'L'
                return
            }
            let temp = ylTableList.value.filter((o) => {
                return o.yarnSource === record.yarnSource && o.staple != record.staple
            })
            if (temp.length > 0) {
                Message.warning('纱支代码:' + record.yarnSource + '已被使用！')
                record.yarnSource = ''
                return
            }
        }
        const delYl = () => {
            let keys = selectedRowKeys.value
            ylTableList.value = ylTableList.value.filter((o) => {
                return !keys.includes(o.yarnSource)
            })
            //找到此排纱对应的删除掉的原料信息
            psList.value = psList.value.filter(function (o: any) {
                return !keys.includes(o[1]['val'])
            })

            selectedRowKeys.value = []
            getGrayFabricName()
        }

        // 成分 组织排针
        const zzpzListSelect = ref<any>([])
        const zzpzid = ref()
        const zzpzdata = ref<any[]>([
            {
                upBasin: '',
                belowBasin: '',
                id: '',
                pdOrganizationPinId: '',
            },
        ])
        const colNumber = ref<number>(1)
        // 设置组织排针列数确认
        const addZhen = () => {
            let n = colNumber.value - zzpzdata.value.length
            if (n < 0) {
                for (let i = n; i < 0; i++) {
                    zzpzdata.value.pop()
                }
            } else if (n > 0) {
                for (let i = 0; i < n; i++) {
                    zzpzdata.value.push({
                        upBasin: '',
                        belowBasin: '',
                        id: '',
                        pdOrganizationPinId: '',
                    })
                }
            } else {
                return
            }
        }
        const zzpzid2 = ref()
        const minsZhen = () => {
            if (zzpzdata.value.length == 1) {
                Message.warning('最少保留一列排针！')
                return
            }
            zzpzdata.value.length = zzpzdata.value.length - 1
        }

        const zzpzok = () => {
            //sessionStorage.setItem("组织排针",JSON.stringify(zzpzid.value))
            if (zzpzid.value == undefined || zzpzid.value == '') {
                Message.warning('请选择组织排针！')
                zzpzdata.value = [
                    {
                        upBasin: '',
                        belowBasin: '',
                        id: '',
                        pdOrganizationPinId: '',
                    },
                ]
                colNumber.value = 1
                zzpzid2.value = 1
                return
            }
            post({
                url: '/product/organizationPin/select',
                data: {
                    id: zzpzid.value,
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    data.map((o: any) => {
                        // o.belowBasin = ''
                        o.id = undefined
                    })
                    console.log(data)
                    zzpzdata.value = data
                    colNumber.value = data.length
                    zzpzid2.value = zzpzid.value
                }
            })
        }
        // 初始化成分-组织排针下拉框
        const zzpzfocus = () => {
            zzpzSelect('')
        }
        const zzpzSelect = (val: any) => {
            post({
                url: 'product/organizationPin/greyExtendValue',
                data: {
                    organizationName: val,
                    deleteState: 0,
                },
            }).then((res) => {
                if (res.code === 200) {
                    zzpzListSelect.value = res.data
                }
            })

        }
        // 初始化成分-裁口排针下拉框
        const ckpzfocus = () => {
            ckpzSelect('')
        }
        //  裁口排针
        const ckpzSelectList = ref<any[]>([])
        const ckpzSelect = (val: any) => {
            post({
                url: 'product/pdCuttingMouthNeedle/getList',
                data: {
                    cmdName: val,
                    deleteState: 0,
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    ckpzSelectList.value = data
                }
            })
        }
        const ckpzid = ref()
        const ckpzobj = reactive<any>({
            id: 0,
            pinHeader: '',
            arrangement: '',
            cmdName: '',
        })
        const ckpzadd = () => {
            if (ckpzid.value == undefined || ckpzid.value == '') {
                Message.warning('请选择裁口排针！')
                ckpzobj.id = 0
                ckpzobj.pinHeader = ''
                ckpzobj.arrangement = ''
                ckpzobj.cmdName = ''
                return
            }
            const obj: any = ckpzSelectList.value.filter((o: any) => o.id === ckpzid.value)[0]
            ckpzobj.id = obj.id
            ckpzobj.pinHeader = obj.pinHeader
            ckpzobj.arrangement = obj.arrangement
            ckpzobj.cmdName = obj.cmdName
            // ckpzid.value = ''
        }
        const copyckpz = () => {
            post({
                url: 'product/pdCuttingMouthNeedle/copyCuttingMouthNeedle',
                data: {
                    id: ckpzobj.id,
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    ckpzobj.id = data.id
                    ckpzobj.arrangement = data.arrangement
                    ckpzobj.pinHeader = data.pinHeader
                }
            })
        }

        const sjdata = reactive<{
            sjid: string | number
            sj: any[]
            atCode: string
            atName: string
            remark: string
        }>({
            sjid: '',
            sj: [],
            atCode: '',
            atName: '',
            remark: '',
        })
        const sjname = ref('')
        const sjSelectList = ref<any[]>([])

        const sjOk = () => {
            paishabiaoji.value = 0
            post({
                url: 'product/arrangementTriangleInfo/getInfoByAtId?id=' + sjid.value,
                data: {
                    atName: sjname,
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    huancunpanduanziduan.value = ''
                    let info = data.info
                    xuanzepaisanjiaolist.value = data.info
                    if (info.length > 0) {
                        if (info[0].typeData.length > 0) {
                            // numb.col = (info[0].typeData[0].needleList).length;

                            xuanhuancihu.value = 1
                            numb.col = info[0].typeData[0].needleList.length
                            info.map((o: any, index: any) => {
                                numb.row[index] = o.typeData.length
                            })
                            //  numb.row[0]=info[0].typeData.length
                            //    numb.row[1]=info[1].typeData.length
                            shikaishu.value = numb.col
                        } else {
                            //  numb.col = 1;
                            //shikaishu.value = 1
                        }
                    } else {
                        //  numb.col = 1;
                        //shikaishu.value = 1
                    }
                    xhCol.value = []
                    // for (let i = 0; i <= numb.col; i++) {
                    //     xhCol.value.push({ val: i })
                    // }
                    for (let i = 0; i <= numb.col; i++) {
                        xhCol.value.push({ val: i })
                    }
                    //排纱 数据
                    RendPs(2)
                    //sjid.value = ''
                    sjdata.sjid = data.id
                    sjdata.sj = data.info
                    if (sjdata.sj.length === 1) {
                        dataForm.models = '1'
                    } else {
                        dataForm.models = '2'
                    }
                    ; (sjdata.atCode = data.atCode), (sjdata.atName = data.atName)
                    sjdata.remark = data.remark
                }
            })
        }
        const sjid = ref()
        const focusSj = () => {
            post({
                url: 'product/arrangementTriangle/getList',
                data: {
                    atName: '',
                    obsoleteState: 0,
                    deleteState: 0,
                    models:
                        dataForm.machineType == null
                            ? undefined
                            : dataForm.machineType == ''
                                ? undefined
                                : dataForm.machineType,
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    sjSelectList.value = data
                }
            })
        }
        const sjSelect = (val: any) => {
            post({
                url: 'product/arrangementTriangle/getList',
                data: {
                    atName: val,
                    obsoleteState: 0,
                    deleteState: 0,
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    sjSelectList.value = data
                }
            })
        }

        function doRefresh() {
            pageData.pageLoading = true
            if (shenhebiaoji.value == 1) {
                post({
                    url: 'product/pdGreyInformation/selectpdGreyInformationPage',
                    data: {
                        page: page.value,
                        size: size.value,
                        deleteState: 0,
                        greyCode: pageData.dropDownData,
                        grayFabricName: pageData.dropDownData2,
                        productKind: pageData.dropDownData4,
                        auditState: 0,
                    },
                })
                    .then(({ data, code }: any) => {
                        if (code === 200) {
                            gridOption.value.setRowData(data.list)
                            table.handleSuccess(data.list)
                            total.value = data.total
                            allDataList = data.list
                        }
                    })
                    .catch(console.log)
                    .finally(() => {
                        pageData.pageLoading = false
                    })
            } else {
                post({
                    url: 'product/pdGreyInformation/selectpdGreyInformationPage',
                    data: {
                        page: page.value,
                        size: size.value,
                        deleteState: 0,
                        greyCode: pageData.dropDownData,
                        grayFabricName: pageData.dropDownData2,
                        productKind: pageData.dropDownData4,
                        auditState: 1,
                    },
                })
                    .then(({ data, code }: any) => {
                        if (code === 200) {
                            gridOption2.value.setRowData(data.list)
                            table.handleSuccess(data.list)
                            total.value = data.total
                            allDataList = data.list
                        }
                    })
                    .catch(console.log)
                    .finally(() => {
                        pageData.pageLoading = false
                    })
            }
        }

        const { selectedRowKeys, onSelectionChange } = useRowSelection()

        const pagination = usePagination(doRefresh)
        const table = useTable()
        const rowKey = useRowKey('id')
        const tableColumns = useTableColumn([
            {
                title: '坯布编号',
                key: 'greyCode',
                dataIndex: 'greyCode',
                width: 150,
            },
            {
                title: '坯布名称',
                key: 'grayFabricName',
                dataIndex: 'grayFabricName',
                width: 150,
            },

            {
                title: '纱线类别',
                key: 'yarnCountCategory',
                dataIndex: 'yarnCountCategory',
                width: 150,
            },
            // {
            //   title: '产品类型',
            //   key: 'productKind',
            //   dataIndex: 'productKind',
            //   width: 150,
            // },

            // {
            //     title: "布类名称",
            //     key: "clothKindOfName",
            //     dataIndex: "clothKindOfName",
            //     width: 150
            // },
            {
                title: '加工单价',
                key: 'machineUnit',
                dataIndex: 'machineUnit',
                width: 150,
            },
            {
                title: '织机转速',
                key: 'loomRevolution',
                dataIndex: 'loomRevolution',
                width: 150,
            },
            {
                title: '机型',
                key: 'machineType',
                dataIndex: 'machineType',
                width: 150,
            },

            {
                title: '机型产量',
                key: 'activeOutput',
                dataIndex: 'activeOutput',
                width: 150,
            },
            {
                title: '针数',
                key: 'needleCount',
                dataIndex: 'needleCount',
                width: 150,
            },
            {
                title: '寸数',
                key: 'dimensionFigure',
                dataIndex: 'dimensionFigure',
                width: 150,
            },
            {
                title: '总针数',
                key: 'sumNeedleCount',
                dataIndex: 'sumNeedleCount',
                width: 150,
            },

            {
                title: '针型',
                key: 'needleType',
                dataIndex: 'needleType',
                width: 150,
            },
            {
                title: '颜色属性',
                key: 'colorAttribute',
                dataIndex: 'colorAttribute',
                width: 150,
            },

            {
                title: '面料种类',
                key: 'fabricType',
                dataIndex: 'fabricType',
                width: 150,
            },
            {
                title: '布类',
                key: 'mercery',
                dataIndex: 'mercery',
                width: 150,
            },
            {
                title: '坯布组织',
                key: 'organization',
                dataIndex: 'organization',
                width: 150,
            },
            {
                title: '坯布功能',
                key: 'feature',
                dataIndex: 'feature',
                width: 150,
            },
            {
                title: '胶管名称',
                key: 'sebificDuctName',
                dataIndex: 'sebificDuctName',
                width: 150,
            },
            {
                title: '库存上限',
                key: 'inventoryUpperLimit',
                dataIndex: 'inventoryUpperLimit',
                width: 150,
            },
            {
                title: '库存下限',
                key: 'inventoryLowerLimit',
                dataIndex: 'inventoryLowerLimit',
                width: 150,
            },
            {
                title: '织造备注',
                key: 'weavingNote',
                dataIndex: 'weavingNote',
                width: 150,
            },
            // {
            //     title: "备注",
            //     key: "remark",
            //     dataIndex: "remark",
            //     width: 150
            // },
            // {
            //     title: "关联商品",
            //     key: "associatedGoods",
            //     dataIndex: "associatedGoods",
            //     width: 150
            // },

            {
                title: '编辑',
                key: 'edit',
                dataIndex: 'edit',
                slotName: 'edit',
                width: 150,
                fixed: 'right',
            },
        ])
        const tableColumns1 = useTableColumn([
            {
                title: '用纱代码',
                key: 'yarnSource',
                dataIndex: 'yarnSource',
                width: 150,
                slotName: 'yarnSource',
            },
            {
                title: '原料编号',
                key: 'yarnCode',
                dataIndex: 'yarnCode',
                width: 150,
            },
            {
                title: '原料名称',
                key: 'staple',
                dataIndex: 'staple',
                width: 150,
            },
            {
                title: '色号',
                key: 'colourNumber',
                dataIndex: 'colourNumber',
                width: 150,
                slotName: 'colourNumber',
            },
            {
                title: '色称',
                key: 'colorAccording',
                dataIndex: 'colorAccording',
                width: 150,
                slotName: 'colorAccording',
            },
            {
                title: '等级',
                key: 'grade',
                dataIndex: 'grade',
                width: 150,
                slotName: 'grade',
            },
            {
                title: "纱线单位",
                key: "yarnUnits",
                dataIndex: "yarnUnits",
                width: 150,
                slotName: 'yarnUnits',

            },
            {
                title: '丹尼尔系数',
                key: 'danielCoefficient',
                dataIndex: 'danielCoefficient',
                width: 150,
            },
            {
                title: '纱支比例(%)',
                key: 'yarnCountProportion',
                dataIndex: 'yarnCountProportion',
                width: 150,
                slotName: 'yarnCountProportion',
            },
            {
                title: '实测纱比(%)',
                key: 'actualYarn',
                dataIndex: 'actualYarn',
                width: 150,
                slotName: 'actualYarn',
            },
            {
                title: '是否超出范围',
                key: 'yujing',
                dataIndex: 'yujing',
                width: 150,
                slotName: 'yujing',
            },
            {
                title: '织布损(%)',
                key: 'weavingDamage',
                dataIndex: 'weavingDamage',
                width: 150,
                slotName: 'weavingDamage',
            },
            {
                title: '颜色组号',
                key: 'colorGroup',
                dataIndex: 'colorGroup',
                width: 150,
                slotName: 'colorGroup',
            },
            {
                title: '循环间距',
                key: 'circularSpacing',
                dataIndex: 'circularSpacing',
                width: 150,
                slotName: 'circularSpacing',
            },
            // {
            //     title: "间距比",
            //     key: "gapRatio",
            //     dataIndex: "gapRatio",
            //     width: 150,
            //     slotName: "gapRatio"
            // },
            {
                title: '纱长',
                key: 'yarnLong',
                dataIndex: 'yarnLong',
                width: 150,
                slotName: 'yarnLong',
            },
            {
                title: '路数',
                key: 'wayNum',
                dataIndex: 'wayNum',
                width: 150,
                slotName: 'wayNum',
            },
        ])
        const dataForm = reactive<RawMaterialsList>({
            orderMachineType: '',
            exploitCode: '',
            shipperUnits: '',
            activeOutput: 0,
            clothKindOfName: '',
            loomRevolution: 0,
            yarnCountCode: '',
            sebificDuctName: '',
            id: '',
            starts: '',
            yarnCountCategory: '',
            playingCards: '',
            updateName: '',
            greyCode: '',
            inventoryLowerLimit: '',
            beadJuggle: '',
            knittingNeedleType: '',
            productKind: '',
            unit: '',
            versions: '',
            associatedGoods: '',
            dimensionFigure: 0,
            grade: '',
            createName: '',
            colorAccording: '',
            needleType: '',
            englishName: '',
            weaverPrice: 0,
            machineUnit: 0,
            weavingDamage: 0,
            actualYarn: 0,
            yarnCountIngredient: '',
            remark: '',
            productTime: '',
            measuredYarnCount: '',
            fabricType: '',
            alwaysGoes: 0,
            needleCount: 0,
            feature: '',
            mercery: '',
            sumNeedleCount: null,
            colorGroup: '',
            machineType: '',
            deleteState: 0,
            outsideProcessingClient: '',
            ingredient: '',
            englishIngredient: '',
            weavingNote: '',
            chineseIngredient: '',
            yarnSource: '',
            staple: '',
            yarnKind: '',
            stockNature: '',
            sYarnProperty: '',
            danielCoefficient: '',
            yarnCountProportion: 0,
            inventoryDivisionMachine: '',
            colorAttribute: '',
            theoryCapacity: 0,
            updateTime: '',
            grayFabricName: '',
            drawnNeedleState: 2,
            scutchingState: '2',
            putOnRecordsCode: '',
            yarnCountName: '',
            createTime: '',
            organization: '',
            commodityState: '',
            category: '',
            inventoryUpperLimit: '',
            circulationGap: '',
            popularizeCommodity: '',
            finishedLimit: '',
            finishedWeight: '',
            colourNumber: 0,
            models: '2',
            processType: 0,
            rubberTube: '',
            checkUnits: '',
            perchPrice: 0,
            perchUnits: '',
            yarnLength: '',
            theoreticalYield: 0
        })

        //下拉框得到焦点
        const focusSel = () => {
            selCxAll({ greyCode: '' })
        }
        //下拉框得到焦点
        const focusSel1 = () => {
            selCxAll1({ materialsName: '', auditState: 1 })
        }
        //下拉框得到焦点
        const focusSel2 = () => {
            selCxAll2({ grayFabricName: '' })
        }
        //下拉框得到焦点
        const focusSel3 = () => {
            selCxAll3({ model: '' })
        }
        let typeNum: any = null
        //下拉框得到焦点
        const focusSel4 = (num: any) => {
            typeNum = num
            if (num == 2) {
                selCxAll4({ productTypeName: '' })
            } else {
                selCxAll4({ productKind: '' })
            }
        }
        //下拉框得到焦点
        const focusSel9 = (num: any) => {
            typeNum = num
            if (num == 2) {
                selCxAll9({ productTypeName: '' })
            }
        }
        const focusSel6 = () => {
            selCxAll6({
                categoryName: '',
            })
        }
        // 针数下拉框
        const focusNeedleCountList = () => {
            getNeedleCountList({ model: '' })
        }
        // 机型下拉框
        const focusMachineTypeList = () => {
            // getMachineTypeList({ machineName: "" })
            jitaileixing()

        }
        // 颜色属性
        const focusColorAttribute = () => {
            getColorAttributeList({ colorattribute: '' })
        }
        // 单位
        const focusunit = () => {
            getUnitList()
        }
        // 初始化成分-原料下拉框
        const focusYl = () => {
            ylSelect('')
        }

        //下拉数据  坯布编号
        const options = ref<any>(pageData.codeList)
        const loading = ref(false)
        const handleSearch = (value: any) => {
            if (value) {
                const ob = { greyCode: value }
                loading.value = true

                selCxAll(ob)
                options.value = pageData.codeList
                loading.value = false
            } else {
                options.value = []
            }
        }

        //下拉框查询 坯布编号
        function selCxAll(val: any) {
            post({
                url: 'product/Rawmaterial/getGreyDrop',
                data: val,
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    // (data as string[]).splice(0, 0, "全部");
                    pageData.codeList = data
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
        }

        //下拉数据 名称
        const options1 = ref<any>(pageData.nameList)
        const loading1 = ref(false)
        const handleSearch1 = (value: any) => {
            if (value) {
                const ob = { materialsName: value }
                loading.value = true

                selCxAll1(ob)
                options.value = pageData.nameList
                loading.value = false
            } else {
                options.value = []
            }
        }

        //下拉框查询 名称
        function selCxAll1(val: any) {
            post({
                url: 'product/Rawmaterial/getRawmaterialsNameDrop',
                data: val,
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageData.nameList = data
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
        }

        //下拉数据  坯布名称
        const options2 = ref<any>(pageData.nameList1)
        const loading2 = ref(false)
        const handleSearch2 = (value: any) => {
            if (value) {
                const ob = { grayFabricName: value }
                loading.value = true

                selCxAll2(ob)
                options.value = pageData.nameList1
                loading.value = false
            } else {
                options.value = []
            }
        }

        //下拉框查询 坯布名称
        function selCxAll2(val: any) {
            post({
                url: 'product/Rawmaterial/getGreyDrop',
                data: val,
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    // (data as string[]).splice(0, 0, "全部");
                    pageData.nameList1 = data
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
        }

        //下拉数据  规格
        const options3 = ref<any>(pageData.ggList)
        const loading3 = ref(false)
        const handleSearch3 = (value: any) => {
            if (value) {
                const ob = { model: value }
                loading.value = true

                selCxAll3(ob)
                options.value = pageData.ggList
                loading.value = false
            } else {
                options.value = []
            }
        }

        //下拉框查询 规格
        function selCxAll3(val: any) {
            post({
                url: 'product/Rawmaterial/getRawmaterialsNameDrop',
                data: val,
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    // (data as string[]).splice(0, 0, "全部");
                    pageData.ggList = data
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
        }

        //通用
        const tags = [
            { id: '1', val: '̶' },
            { id: '2', val: 'Ո' },
            { id: '3', val: 'Ս' },
            { id: '4', val: 'Ʌ' },
            {
                id: '5',
                val: 'V',
            },
        ]

        // const tags2=[{ id: '1', val: '̶' }, { id: '2', val: "Ո" }, { id: '4', val: 'Ʌ' }]
        //下拉数据 分类
        const options4 = ref<any>(pageData.flList)
        const loading4 = ref(false)
        const handleSearch4 = (value: any) => {
            if (value) {
                let ob = {}
                if (typeNum == 2) {
                    ob = { productTypeName: value }
                } else {
                    ob = { productKind: value }
                }
                loading.value = true
                selCxAll4(ob)
                options.value = pageData.flList
                loading.value = false
            } else {
                options.value = []
            }
        }

        //下拉框查询 分类
        function selCxAll4(val: any) {
            if (typeNum == 2) {
                post({
                    url: 'product/Rawmaterial/getProductTypeDrop',
                    data: val,
                }).then(({ data, code }: any) => {
                    if (code === 200) {
                        // (data as string[]).splice(0, 0, "全部");
                        pageData.flList = data
                    } else {
                        Message.error({
                            content: '查询失败！',
                            duration: 5000,
                        })
                    }
                })
            } else {
                post({
                    url: 'product/pdGreyInformation/getFieldValue',
                    data: val,
                }).then(({ data, code }: any) => {
                    if (code === 200) {
                        // (data as string[]).splice(0, 0, "全部");
                        pageData.flList = data
                    } else {
                        Message.error({
                            content: '查询失败！',
                            duration: 5000,
                        })
                    }
                })
            }
        }

        //下拉框查询 分类
        function selCxAll9(val: any) {
            if (typeNum == 2) {
                post({
                    url: 'product/rubberhoseSet/getList',
                    data: val,
                }).then(({ data, code }: any) => {
                    if (code === 200) {
                        // (data as string[]).splice(0, 0, "全部");
                        pageData.flList = data
                    } else {
                        Message.error({
                            content: '查询失败！',
                            duration: 5000,
                        })
                    }
                })
            }
        }

        //下拉数据 组织
        const options6 = ref<any>(pageData.zuzhiList)
        const loading6 = ref(false)
        const handleSearch6 = (value: any) => {
            if (value) {
                const ob = { categoryName: value }
                loading6.value = true
                selCxAll6(ob)
                options6.value = pageData.zuzhiList
                loading6.value = false
            } else {
                options6.value = []
            }
        }

        //下拉框查询 组织
        function selCxAll6(val: any) {
            post({
                url: 'product/pdGreyInformationOrganization/getFieldValue',
                data: val,
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageData.zuzhiList = data
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
        }

        // 针数下拉框
        const searchNeedleCountList = (value: any) => {
            if (value) {
                const ob = { model: value }
                loading.value = true
                getNeedleCountList(ob)
                options.value = pageData.needleCountList
                loading.value = false
            } else {
                options.value = []
            }
        }
        const getNeedleCountList = (val: any) => {
            post({
                url: 'product/workdrumEquipment/getnumber',
                data: val,
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    // (data as string[]).splice(0, 0, "全部");
                    pageData.needleCountList = data
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
            // post({
            //     url: 'product/greyExtend/greyExtendByNumberThreads',
            //     data: val
            // }).then(({ code, data }: any) => {
            //     if (code === 200) {
            //         pageData.needleCountList = data;
            //     } else {
            //         Message.error({
            //             content: '查询失败',
            //             duration: 5000
            //         })
            //     }

            // })
        }
        // 机型下拉框
        const searchMachineTypeList = (value: any) => {
            if (value) {
                const ob = { machineName: value }
                loading.value = true
                getMachineTypeList(ob)
                options.value = pageData.machineTypeList
                loading.value = false
            } else {
                options.value = []
            }
        }
        // 机型下拉框
        const getMachineTypeList = (val: any) => {
            post({
                url: 'product/GreyMachinetype/getFieldValue',
                data: val,
            }).then(({ code, data }: any) => {
                if (code === 200) {
                    pageData.machineTypeList = data
                } else {
                    Message.error({
                        content: '查询失败',
                        duration: 5000,
                    })
                }
            })
        }
        // 颜色属性下拉框
        const searchColorAttribute = (value: any) => {
            if (value) {
                const ob = { colorattribute: value }
                loading.value = true
                getColorAttributeList(ob)
                options.value = pageData.colorAttributeList
                loading.value = false
            } else {
                options.value = []
            }
        }
        // 颜色属性下拉框
        const getColorAttributeList = (val: any) => {
            post({
                url: 'product/greyColorattribute/getFieldValue',
                data: val,
            }).then(({ code, data }: any) => {
                if (code === 200) {
                    pageData.colorAttributeList = data
                } else {
                    Message.error({
                        content: '查询失败',
                        duration: 5000,
                    })
                }
            })
        }
        // 单位下拉框
        const searchUnit = (value: any) => {
            if (value) {
                const ob = {
                    field: 'unit',
                    value: value,
                }
                loading.value = true
                getUnitList()
                options.value = pageData.unitList
                loading.value = false
            } else {
                options.value = []
            }
        }
        // 单位下拉框
        const getUnitList = () => {
            post({
                url: 'dict/dictTypeDetail/getListByCodeType?codeType=17',
            }).then(({ code, data }: any) => {
                if (code == 200) {
                    pageData.unitList = data
                } else {
                    Message.error({
                        content: '查询失败',
                        duration: 5000,
                    })
                }
            })
        }

        const ylSelect = (val: any) => {
            post({
                url: 'product/Rawmaterial/getInfo',
                data: {
                    materialsName: val,
                },
            }).then((res) => {
                if (res.code === 200) {
                    ylList.value = res.data
                }
            })
        }
        onMounted(() => {
            // 切换tap到本页面执行的方法
            emitter.on('EmbroideryList', () => {
                selCxAll({})
                doRefresh()

                //根据账号类型判断是否本集团
            })
            // getwuliao({ materialName: '',auditState:1})
            pageData.rHeight = document.getElementsByClassName('arco-tabs-content')[0]?.clientHeight
            //弹出层的高
            if (pageData.rHeight !== undefined) {
                pageData.rHeight = pageData.rHeight - 100
            }
            window.addEventListener('resize', () => {
                pageData.rHeight = document.getElementsByClassName('arco-tabs-content')[0]?.clientHeight
                //弹出层的高
                if (pageData.rHeight !== undefined) {
                    pageData.rHeight = pageData.rHeight - 100
                }
            })
        })
        //查询
        const selectHandler = () => {
            page.value = 1
            doRefresh()
        }
        const queryData = reactive({
            firm: '',
        })
        const addHandler = () => {
            shabili()
            // shifoubenjituan();
            xuanzepaisanjiaolist.value = []
            crossMemo.value = ''
            machineUnit.value = 0
            shikaishu.value = 1
            xuanhuancihu.value = 1
            theoryPrice.value = 0
            psList.value = []
            shifoubenjituan()
            machineUnit.value = 0
            pageData.ylCfIdList = []
            selectedRowKeys.value = []
            pageData.isDetails = false
            pageData.zhong = ''
            pageData.yin = ''
            sjdata.atCode = ''
            sjdata.atName = ''
            sjdata.remark = ''
            sjdata.sjid = ''
            sjid.value = ''
            sjdata.sj = []
            zzpzdata.value = []
            zzpzid.value = ''
            zzpzid2.value = []
            ckpzid.value = ''
            ckpzobj.arrangement = ''
            ckpzobj.pinHeader = ''
            ckpzobj.id = 0
            ckpzobj.id = 0
            ylId.value = ''
            colNumber.value = 0
            ylTableList.value.length = 0
            pageData.spRowList = []
            Object.keys(dataForm).forEach((o) => {
                if (
                    o == 'activeOutput' ||
                    o == 'loomRevolution' ||
                    o == 'weaverPrice' ||
                    o == 'alwaysGoes' ||
                    o == 'deleteState' ||
                    o == 'theoryCapacity' ||
                    o == 'processType' ||
                    o == 'machineUnit' ||

                    o == 'perchPrice' || o == 'theoreticalYield'
                ) {
                    dataForm[o] = 0
                } else if (o == 'scutchingState') {
                    dataForm[o] = 2
                } else {
                    dataForm[o] = ''
                }
                if (o == 'drawnNeedleState') {
                    dataForm[o] = 2
                }
            })
            pageData.showAdd = true
            pageData.sideTitle = '新增坯布'
            numb.col = 1
            numb.row = [2, 4]

            sjdata.sj = [
                {
                    type: '上盘',
                    typeData: [
                        {
                            serialNumber: 1,
                            needleName: '',
                            needleList: [
                                {
                                    needle: '',
                                    way: 1,
                                },
                            ],
                        },
                        {
                            serialNumber: 2,
                            needleName: '',
                            needleList: [
                                {
                                    needle: '',
                                    way: 1,
                                },
                            ],
                        },
                    ],
                },
                {
                    type: '下盘',
                    typeData: [
                        {
                            serialNumber: 1,
                            needleName: '',
                            needleList: [{ way: 1 }],
                        },
                        {
                            serialNumber: 2,
                            needleName: '',
                            needleList: [
                                {
                                    needle: '',
                                    way: 1,
                                },
                            ],
                        },
                        {
                            serialNumber: 3,
                            needleName: '',
                            needleList: [
                                {
                                    needle: '',
                                    way: 1,
                                },
                            ],
                        },
                        {
                            serialNumber: 4,
                            needleName: '',
                            needleList: [
                                {
                                    needle: '',
                                    way: 1,
                                },
                            ],
                        },
                    ],
                },
            ]
            xhCol.value = []
            // for (let i = 0; i <= numb.col; i++) {
            //     xhCol.value.push({ val: i })
            // }
            for (let i = 0; i <= numb.col; i++) {
                xhCol.value.push({ val: i })
            }
            dataForm.models = '2'
        }
        let xhCol = ref<any[]>([])
        const ewsj = ref<any>([])
        //修改 record（本行数据）
        const editHandler = (record: any, num: any) => {
            focusPs()
            //唐威加
            //shifoubenjituan();
            shabili()
                // psList.value = [];
                ; (paishabiaoji.value = 0), (huancunpanduanziduan.value = '')
            sjdata.sj = []

            ylTableList.value = []
            zzpzSelect('')
            id.value = record.id
            // -----------
            pageData.ylCfIdList = []
            selectedRowKeys.value = []
            if (num == 2) {
                pageData.isDetails = true
            } else {
                pageData.isDetails = false
            }
            pageData.zhong = ''
            pageData.yin = ''
            const idToData = allDataList.filter((item) => item.id == record.id)

            post({
                url: 'product/pdGreyInformation/select',
                data: {
                    id: record.id,
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    // 原料列表
                    for(let item in data.greyInformation){
                        dataForm[item] = data.greyInformation[item]
                    }
                    ylTableList.value = data.yarnStructures
                    ylTableList.value.forEach(function (o: any) {
                        pageData.ylCfIdList.push(o['ylId'])
                    })
                    //tw加
                    ylTableList.value.forEach((o: any) => {
                        var cha = o.actualYarn - o.yarnCountProportion
                        for (let item of shabilist.value) {
                            if (cha >= Number(item['yarnCountMin']) && cha <= Number(item['yarnCountMax'])) {
                                o.jieguo = 1
                                break
                            } else {
                                o.jieguo = 2
                            }
                        }
                    })
                    // machineUnit.value = data.greyInformation.machineUnit
                    dataForm.processType = data.greyInformation.processType
                    crossMemo.value = data.greyInformation.crossMemo
                    dataForm.alwaysGoes = Number(data.greyInformation.alwaysGoes)
                    theoryPrice.value = data.greyInformation.theoryPrice
                    if (data.arrangementTriangleGreys['info'] != undefined && data.arrangementTriangleGreys['info'] != null) {
                        data.arrangementTriangleGreys.info.map((o: any) => {
                            o.typeData.map((a: any) => {
                                a.needleList.map((b: any, index: any) => {
                                    if (index == 0) {
                                        xuanhuancihu.value = b.circulationNum
                                        shikaishu.value = b.realOpenNum
                                    }
                                })
                            })
                        })
                    }

                    sjid.value = data.arrangementTriangleGreys.atName
                    ckpzid.value = data.arrangementTriangleGreys.cmdName
                    //---------------
                    // 组织排针 列数
                    colNumber.value =
                        data.organizationPinSons.length == 0 ? 1 : data.organizationPinSons.length
                    // 组织排针 数据
                    zzpzdata.value =
                        data.organizationPinSons.length == 0
                            ? [
                                {
                                    upBasin: '',
                                    belowBasin: '',
                                    id: '',
                                    pdOrganizationPinId: '',
                                },
                            ]
                            : data.organizationPinSons
                    // 裁口排针
                    if (data.cuttingMouthNeedleGrey != null) {
                        let cuttingMouthNeedleGrey = data.cuttingMouthNeedleGrey
                        ckpzobj.id = cuttingMouthNeedleGrey.id
                        ckpzobj.pinHeader = cuttingMouthNeedleGrey.pinHeader
                        ckpzobj.arrangement = cuttingMouthNeedleGrey.arrangement
                        ckpzobj.cmdName = cuttingMouthNeedleGrey.cmdName
                    }
                    //tw加
                    if (data.cuttingMouthNeedleGrey != null && data.cuttingMouthNeedleGrey.length > 0) {
                        ckpzobj.pinHeader = data.cuttingMouthNeedleGrey[0].pinHeader
                        ckpzobj.arrangement = data.cuttingMouthNeedleGrey[0].arrangement
                        ckpzid.value = data.cuttingMouthNeedleGrey[0].cmdName
                    }

                    // 关联商品渲染
                    pageData.spRowList = data.commodities
                    pageData.spRowList.map((o: any) => {
                        o.isban = true
                    })
                    // 排三角arrangementTriangleGreys
                    sjdata.sj = data.arrangementTriangleGreys.info
                    // sjdata.sjid=data.arrangementTriangleGreys.greyId
                    // psjpb.value=data.arrangementTriangleGreys.greyId 现有坯布
                    sjdata.atCode = data.arrangementTriangleGreys.atCode
                    sjdata.atName = data.arrangementTriangleGreys.atName
                    sjdata.remark = data.arrangementTriangleGreys.remark
                    //psList.value = data.atOther
                    if (data.atOther != '' && data.atOther != null) {
                        psList.value = data.atOther
                    }
                    if (data.atOther == '' || data.atOther == null) {
                        var aa = [] as any
                        for (var i = 0; i < ylTableList.value.length + 1; i++) {
                            var shuzu = [] as any
                            for (var j = 0; j <= 2 + shikaishu.value; j++) {
                                if (i > 0 && j == 1) {
                                    var obj2 = {
                                        val: ylTableList.value[i - 1].yarnSource,
                                        text: ylTableList.value[i - 1].staple,
                                    }
                                    shuzu.push(obj2)
                                }
                                if (i == 0 && j == 2) {
                                    var obj = { val: '排纱' }
                                    shuzu.push(obj)
                                }
                                if (i != 0 && j == 0) {
                                    var obj = { val: '纱长(cm)' }
                                    shuzu.push(obj)
                                }
                                if (i == 0 && j != 2) {
                                    var obj3 = { val: '' }
                                    shuzu.push(obj3)
                                }
                                if (i > 0 && j > 1) {
                                    var obj3 = { val: '' }
                                    shuzu.push(obj3)
                                }
                            }

                            aa.push(shuzu)
                        }
                        psList.value = aa
                    }
                    //huoquyuanliaomingcheng();

                    //tw加，机型和组织排针下拉框关联
                    // if (dataForm.machineType == '双间螺纹机' || dataForm.machineType == '螺纹机') {
                    //   zzpzid.value = 37
                    // } else if (dataForm.machineType == '双面机') {
                    //   zzpzid.value = 44
                    // } else if (dataForm.machineType == '单面机') {
                    //   zzpzid.value = 38
                    // }
                }
                if (sjdata.sj == undefined || sjdata.sj == null) {
                    sjdata.sj = []
                }
                if (sjdata.sj.length == 0) {
                }
                if (sjdata.sj.length === 1) {
                    dataForm.models = '1'
                } else {
                    dataForm.models = '2'
                }
                numb.row = sjdata.sj.map((o: any) => {
                    return o.typeData.length
                })
                let maxColNumber = 0
                //tw改
                maxColNumber = shikaishu.value

                //---
                //tw注
                // sjdata.sj[0].typeData[0].needleList.forEach((o: any) => {
                //     if (o.way > maxColNumber) {
                //         maxColNumber = parseInt(o.way)
                //     }
                // })
                numb.col = maxColNumber

                shikaishu.value = maxColNumber
                xhCol.value = []

                numb.col = shikaishu.value / xuanhuancihu.value

                // for (let i = 0; i <= numb.col; i++) {
                //     xhCol.value.push({ val: i })
                // }
                var paishachang = 0
                if (data.atOther != '' && data.atOther != null) {
                    paishachang = data.atOther[0].length - 3
                }
                if (data.atOther == '' || data.atOther == null) {
                    paishachang = shikaishu.value
                }

                // for (let i = 0; i <= shikaishu.value; i++) {
                //     xhCol.value.push({ val: i })
                // }
                for (let i = 0; i <= paishachang; i++) {
                    xhCol.value.push({ val: i })
                }
            })

            if (idToData.length > 0) {
                for (let key in idToData[0]) {
                    dataForm[key] = idToData[0][key]
                }
            }

            ylId.value = ''

            //侧滑栏滑出滑入
            pageData.showAdd = true
            pageData.sideTitle = '修改坯布'
            xhCol.value = []
            // for (let i = 0; i <= numb.col; i++) {
            //     xhCol.value.push({ val: i })
            // }
            for (let i = 0; i <= numb.col; i++) {
                var obj = { val: i }
                //xhCol.value.push({ val: i })
                xhCol.value.push(obj)
            }
        }

        const changeNeedleCount = (val: any) => {
            dataForm.needleCount = undefined
            dataForm.dimensionFigure = undefined
            dataForm.sumNeedleCount = undefined

            pageData.needleCountList.forEach(function (o: any) {
                if (o['model'] == val) {
                    dataForm.needleCount = o['numberThreads']
                    dataForm.dimensionFigure = o['smallNumber']
                    dataForm.sumNeedleCount = o['sumNeedleNum']
                    // dataForm.alwaysGoes = Number(o['sumWay'])
                }
            })
            getTheoreticalYield("")
        }

        const formRef = ref<FormInstance>()
        const formRef1 = ref()
        const sideOk = () => {
            if (dataForm.activeOutput == 0 || dataForm.alwaysGoes == 0) {
                Message.warning({
                    content: '工艺信息里实际产量和总路数不能为0！',
                    duration: 5000,
                })
                return
            }
            if (dataForm.theoreticalYield == 0 || dataForm.theoreticalYield == null) {
                Message.warning({
                    content: '理论产能计算结果为0,请核对参数后重新计算！',
                    duration: 5000,
                })
                return
            }
            let isBtx = false
            for (let index = 0; index < ylTableList.value.length; index++) {
                if (ylTableList.value[index]['yarnUnits'] == "" || ylTableList.value[index]['yarnUnits'] == null || ylTableList.value[index]['yarnCountProportion'] == "" || ylTableList.value[index]['yarnCountProportion'] == null || ylTableList.value[index]['yarnCountProportion'] == 0 || ylTableList.value[index]['weavingDamage'] == "" || ylTableList.value[index]['weavingDamage'] == 0 || ylTableList.value[index]['weavingDamage'] == null || ylTableList.value[index]['yarnLong'] == "" || ylTableList.value[index]['yarnLong'] == 0 || ylTableList.value[index]['wayNum'] == "" || ylTableList.value[index]['wayNum'] == 0) {
                    Message.warning({
                        content: '纱支结构页签内的红色单元格必填！且数字类型的不能为0',
                        duration: 5000,
                    })
                    isBtx = true
                    break;
                }
            }
            if (isBtx) {
                return
            }

            var jj = [] as any
            sjdata.sj.map((o: any) => {
                if (o.show == true || o.show == undefined || o.show == null || o.show == '') {
                    jj.push(o)
                }
            })
            let arrangementTriangle = {}
            if (sjdata.sj.length > 0) {
                arrangementTriangle = {
                    atName: sjdata.atName,
                    atCode: sjdata.atCode,
                    remark: sjdata.atName,
                    info: jj,
                }
            }

            pageData.pageLoading = true
            formRef.value?.validate().then((err) => {
                if (!err) {

                    //tw加

                    //添加
                    //     dataForm['organizationPinId'] = zzpzid2.value
                    //     dataForm['cutMouthNeedleId'] = ckpzobj.id
                    //     dataForm['arrangementId'] = sjid.value

                    let data1 = {}
                    data1['psj'] = {
                        atName: sjdata.atName,
                        atCode: sjdata.atCode,
                        remark: sjdata.atName,
                        info: sjdata.sj,
                    }

                    data1['ckpz'] = ckpzobj
                    data1['zzpz'] = zzpzdata.value
                    data1['yl'] = ylTableList.value
                    data1['sp'] = ''
                    // 拼接额外信息
                    let ewsjArr: any[] = []
                    ewsj.value.forEach((o: any) => {
                        ewsjArr = ewsjArr.concat(...o)
                    })
                    //hcw 新加 整合新增接口 排三角
                    // let arrangementTriangle = {};
                    // if (sjdata.sj.length > 0) {
                    //     arrangementTriangle = {
                    //         atName: sjdata.atName,
                    //         atCode: sjdata.atCode,
                    //         remark: sjdata.atName,
                    //         info: sjdata.sj
                    //     };
                    // }
                    let organizationPinSon = {}
                    if (data1['zzpz'] != null) {
                        let zzpzOb = zzpzListSelect.value.filter((item: any) => item.id == zzpzid.value)[0]
                        organizationPinSon = {
                            organizationName: zzpzOb == undefined ? '' : zzpzOb.organizationName,
                            list: data1['zzpz'],
                        }
                    }
                    //循环用户选中的商品 取id
                    let commodityGreyList: any = []
                    pageData.spRowList.forEach(function (o: any) {
                        if (o['isban'] == true) {
                            commodityGreyList.push(o['id'])
                        }
                    })

                    //原料列表、
                    let yarnStructure = ylTableList.value
                    let greyInformations = dataForm
                    ckpzobj.id = undefined
                    if (greyInformations['drawnNeedleState'] == "" || greyInformations['drawnNeedleState'] == null) {
                        if (greyInformations['drawnNeedleState'] + "" !== "0") {
                            greyInformations['drawnNeedleState'] = 2
                        }

                    }
                    if (greyInformations['scutchingState'] == "" || greyInformations['scutchingState'] == null) {
                        if (greyInformations['scutchingState'] + "" !== "0") {
                            greyInformations['scutchingState'] = 2
                        }
                    }
                    if (pageData.sideTitle === '新增坯布') {
                        // //添加
                        // dataForm['organizationPinId'] = zzpzid2.value
                        // dataForm['cutMouthNeedleId'] = ckpzobj.id
                        // dataForm['arrangementId'] = sjid.value
                        // let data1 = {}
                        // data1["psj"] = {
                        //     atName: sjdata.atName,
                        //     atCode: sjdata.atCode,
                        //     remark: sjdata.atName,
                        //     info: sjdata.sj
                        // }
                        // data1['ckpz'] = ckpzobj
                        // data1['zzpz'] = zzpzdata.value
                        // data1['yl'] = ylTableList.value
                        // data1['sp'] = ''
                        // // 拼接额外信息
                        // let ewsjArr: any[] = []
                        // ewsj.value.forEach((o: any) => {
                        //     ewsjArr = ewsjArr.concat(...o)
                        // })
                        // if (sjdata.sjid === '') {
                        //     let newsjid: any = await post({
                        //         url: 'product/arrangementTriangle/insert',
                        //         data: {
                        //             atName: sjdata.atName,
                        //             atCode: sjdata.atCode,
                        //             remark: sjdata.atName,
                        //             info: sjdata.sj
                        //         }
                        //     })
                        //     if (newsjid.code === 200) {
                        //         sjdata.sjid = newsjid.data
                        //     } else {
                        //         Message.error(newsjid.message)
                        //         return
                        //     }
                        // } else {
                        //     let newsjid: any = await post({
                        //         url: 'product/arrangementTriangle/update',
                        //         data: {
                        //             id: sjdata.sjid,
                        //             atName: sjdata.atName,
                        //             atCode: sjdata.atCode,
                        //             remark: sjdata.atName,
                        //             info: sjdata.sj
                        //         }
                        //     })
                        //     if (newsjid.code === 200) {
                        //         sjdata.sjid = newsjid.data
                        //     } else {
                        //         Message.error(newsjid.message)
                        //         return
                        //     }
                        // }

                        // greyInformations['machineUnit'] = machineUnit.value
                        greyInformations['theoryPrice'] = theoryPrice.value
                        greyInformations['crossMemo'] = crossMemo.value
                        if (arrangementTriangle['info'] != undefined && arrangementTriangle['info'] != null) {
                            arrangementTriangle['info'].map((o: any) => {
                                o.typeData.map((a: any) => {
                                    a.needleList.map((b: any) => {
                                        b.circulationNum = xuanhuancihu.value
                                        b.realOpenNum = shikaishu.value
                                    })
                                })
                            })

                        }

                        post({
                            url: 'product/pdGreyInformation/insert',
                            data: {
                                arrangementTriangle,
                                organizationPinSon,
                                commodityGreyList,
                                yarnStructure,
                                greyInformations,
                                cuttingMouthNeedleGrey: ckpzobj,
                                atOther: psList.value,
                                // machineUnit: machineUnit.value,
                            },
                        })
                            .then((res: any) => {
                                if (res.code === 200) {
                                    // if (ylTableList.value.length === 0) {
                                    //     return
                                    // }
                                    // ylTableList.value.forEach(function (o) {
                                    //     o["pdGreyInformationId"] = res.data;
                                    // });
                                    // // 新增三角额外信息
                                    // post({
                                    //     url: 'product/greyArrangement/saveGreyArrangement',
                                    //     data: ewsjArr
                                    // })
                                    // // 新增坯布基础资料成功则保存原料信息绑定
                                    // post({
                                    //     url: 'product/yarnStructure/insert',
                                    //     data: ylTableList.value
                                    // }).then((res: any) => {
                                    //     if (res.code === 200) {
                                    //         formRef.value?.resetFields()

                                    //     } else {
                                    //         Message.error({
                                    //             content: res.message,
                                    //             duration: 5000
                                    //         })
                                    //     }
                                    // })
                                    // pageData.showAdd = false
                                    Message.success({
                                        content: '新增成功',
                                        duration: 5000,
                                    })
                                    machineUnit.value = 0
                                    theoryPrice.value = 0
                                    pageData.showAdd = false
                                    doRefresh()
                                } else {
                                    Message.error({
                                        content: res.message,
                                        duration: 5000,
                                    })
                                }
                            })
                            .finally(() => {
                                pageData.pageLoading = false
                            })
                    } else if (pageData.sideTitle === '修改坯布') {
                        // 判断排三角需要
                        // if (sjdata.sjid === '') {
                        //     let newsjid: any = await post({
                        //         url: 'product/arrangementTriangle/insert',
                        //         data: {
                        //             atName: sjdata.atName,
                        //             atCode: sjdata.atCode,
                        //             remark: sjdata.atName,
                        //             info: sjdata.sj
                        //         }
                        //     })
                        //     if (newsjid.code === 200) {
                        //         sjdata.sjid = newsjid.data
                        //     } else {
                        //         Message.error(newsjid.message)
                        //         return
                        //     }
                        // } else {
                        //     let newsjid: any = await post({
                        //         url: 'product/arrangementTriangle/update',
                        //         data: {
                        //             id: sjdata.sjid,
                        //             atName: sjdata.atName,
                        //             atCode: sjdata.atCode,
                        //             remark: sjdata.atName,
                        //             info: sjdata.sj
                        //         }
                        //     })
                        //     if (newsjid.code === 200) {
                        //         sjdata.sjid = newsjid.data
                        //     } else {
                        //         Message.error(newsjid.message)
                        //         return
                        //     }
                        // }

                        //修改
                        //tw加
                        // greyInformations['machineUnit'] = machineUnit.value
                        greyInformations['theoryPrice'] = theoryPrice.value
                        greyInformations['crossMemo'] = crossMemo.value
                        greyInformations['id'] = id.value as any
                        if (arrangementTriangle['info'] != undefined && arrangementTriangle['info'] != null) {
                            arrangementTriangle['info'].map((o: any) => {
                                o.typeData.map((a: any) => {
                                    a.needleList.map((b: any) => {
                                        b.circulationNum = xuanhuancihu.value
                                        b.realOpenNum = shikaishu.value
                                    })
                                })
                            })
                        }
                        post({
                            url: 'product/pdGreyInformation/insert',
                            data: {
                                arrangementTriangle,
                                organizationPinSon,
                                commodityGreyList,
                                yarnStructure,
                                greyInformations,
                                cuttingMouthNeedleGrey: ckpzobj,
                                atOther: psList.value,
                            },
                        })
                            .then(({ data, code, message }: any) => {
                                if (code === 200) {
                                    formRef.value?.resetFields()
                                    Message.success({
                                        content: '修改成功',
                                        duration: 5000,
                                    })
                                    doRefresh()
                                    pageData.showAdd = false
                                } else {
                                    Message.error({
                                        content: message,
                                        duration: 5000,
                                    })
                                }
                            })
                            .finally(() => {
                                pageData.pageLoading = false
                            })
                    } else if (pageData.sideTitle === '复制新增') {
                        // if(fuzhixinzengindex.value==0){
                        //          iscopy('工艺')
                        // } else if(fuzhixinzengindex.value==1){
                        //        iscopy('颜色')
                        // }else{
                        //     iscopy('工艺颜色')
                        // }
                        jinxingfuzhi()
                        pageData.pageLoading = false
                    }
                }
            })

        }
        const deleteHandler = () => {
            if (shenhebiaoji.value == 1) {
                if (gridOption.value.getSelectedRows().length === 0) {
                    Message.error('请先勾选')
                    return
                }
                Modal.confirm({
                    title: '系统提示',
                    content: '确认删除选中的数据?',
                    draggable: true,
                    onOk() {
                        pageData.pageLoading = true
                        post({
                            url: 'product/pdGreyInformation/delete',
                            data: gridOption.value.getSelectedRows().map((o: any) => {
                                return o.id
                            }),
                        })
                            .then(({ code, data, message }: any) => {
                                if (code === 200) {
                                    Message.success({
                                        content: '删除成功',
                                        duration: 5000,
                                    })
                                    pagination.page = 1
                                    doRefresh()
                                } else {
                                    Message.error({
                                        content: message,
                                        duration: 5000,
                                    })
                                }
                            })
                            .finally(() => {
                                pageData.pageLoading = false
                            })
                    },
                })
            } else {
                if (gridOption2.value.getSelectedRows().length === 0) {
                    Message.error('请先勾选')
                    return
                }
                Modal.confirm({
                    title: '系统提示',
                    content: '确认删除选中的数据?',
                    draggable: true,
                    onOk() {
                        pageData.pageLoading = true
                        post({
                            url: 'product/pdGreyInformation/delete',
                            data: gridOption2.value.getSelectedRows().map((o: any) => {
                                return o.id
                            }),
                        })
                            .then(({ code, data, message }: any) => {
                                if (code === 200) {
                                    Message.success({
                                        content: '删除成功',
                                        duration: 5000,
                                    })
                                    pagination.page = 1
                                    doRefresh()
                                } else {
                                    Message.error({
                                        content: message,
                                        duration: 5000,
                                    })
                                }
                            })
                            .finally(() => {
                                pageData.pageLoading = false
                            })
                    },
                })
            }
        }
        //工厂 /编号/单位下拉框改变事件
        const changeFirm = () => {
            post({
                url: 'product/pdGreyInformation/selectpdGreyInformation',
                data: {
                    firm: queryData.firm,
                },
            })
                .then(({ data, code }: any) => {
                    if (code === 200) {
                        table.handleSuccess(data.list)
                        pagination.setTotalSize(data.total)
                    }
                })
                .catch(console.log)
        }
        //设置循环路数按钮点击事件:原来
        const addCol = () => {
            RendPs(2)
            let maxColNumber = 0
            sjdata.sj[0].typeData[0].needleList.forEach((o: any) => {
                if (o.way > maxColNumber) {
                    maxColNumber = parseInt(o.way)
                }
            })
            //let n = maxColNumber - numb.col
            let n = maxColNumber - shikaishu.value
            if (n < 0) {
                for (let i = n; i < 0; i++) {
                    sjdata.sj.forEach((o: any) => {
                        o.typeData.forEach((o1: any, id: number) => {
                            o1.needleList.push({
                                way: maxColNumber + Math.abs(n - i) + 1,
                                needle: '',
                            })
                        })
                    })

                    for (let k = 0; k < psList.value.length; k++) {
                        // for (let j = 0; j < psList.value[k].length; j++) {
                        psList.value[k].push({ val: '' })
                        // }
                    }
                }
            } else if (n > 0) {
                for (let i = 0; i < n; i++) {
                    sjdata.sj.forEach((o: any, i: number) => {
                        o.typeData.forEach((o1: any) => {
                            o1.needleList.pop()
                        })
                    })
                    for (let k = 0; k < psList.value.length; k++) {
                        // for (let j = 0; j < psList.value[k].length; j++) {
                        psList.value[k].pop()
                        // }
                    }
                }
            } else {
                return
            }
            xhCol.value = []
            // for (let i = 0; i <= numb.col; i++) {
            //     xhCol.value.push({ val: i })
            // }
            for (let i = 0; i <= numb.col; i++) {
                xhCol.value.push({ val: i })
            }
        }

        const subCol = () => {
            if (sjdata.sj[0].typeData[0].needleList.length === 1) {
                Message.warning('请至少保留一位路数！')
                return
            }
            sjdata.sj.forEach((o: any, i: number) => {
                o.typeData.forEach((o1: any) => {
                    o1.needleList.pop()
                })
            })
        }
        const addRow = (item: any[]) => {
            // 现有多少行
            let maxRowNumber = 0
            item['typeData'].forEach((o: any) => {
                if (o.serialNumber > maxRowNumber) {
                    maxRowNumber = o.serialNumber
                }
            })
            let index = sjdata.sj.indexOf(item)
            let n = maxRowNumber - numb.row[index]
            if (n < 0) {
                for (let i = n; i < 0; i++) {
                    let nl: any[] = []
                    item['typeData'][0].needleList.forEach((o: any) => {
                        nl.push({
                            way: o.way,
                            needle: '',
                        })
                    })
                    item['typeData'].push({
                        serialNumber: maxRowNumber + Math.abs(n - i) + 1,
                        needleName: '',
                        needleList: nl,
                    })
                }
            } else if (n > 0) {
                for (let i = 0; i < n; i++) {
                    item['typeData'].pop()
                }
            }
        }
        const subRow = (item: any[]) => {
            if (item.length === 1) {
                Message.warning('请最少保留一行！')
                return
            }
            item.pop()
        }

        // 禁止input 只能输入整数
        function setNum(val: any) {
            if (val.upBasin === undefined || parseInt(val.upBasin) + '' === 'NaN') {
                val.upBasin = ''
            } else {
                val.upBasin = parseInt(val.upBasin)
            }
        }

        function setNum1(val: any) {
            if (val.belowBasin === undefined || parseInt(val.belowBasin) + '' === 'NaN') {
                val.belowBasin = ''
            } else {
                val.belowBasin = parseInt(val.belowBasin)
            }
        }

        const tagValue = ref<string>(pageData.tags[0].id)

        const setSJValue = (i2: any, item: any) => {
            // if (dataForm.machineType == "双面机" || dataForm.machineType == "螺纹机") {
            if (item.type == '上盘') {
                if (tagValue.value == '1' || tagValue.value == '3' || tagValue.value == '5') {
                    i2.needle = tagValue.value
                } else {
                    Message.warning({
                        content: dataForm.machineType + '上盘Ո,Ʌ不可选择',
                        duration: 5000,
                    })
                    return
                }
            } else if (item.type == '下盘') {
                if (tagValue.value == '1' || tagValue.value == '2' || tagValue.value == '4') {
                    i2.needle = tagValue.value
                } else {
                    Message.warning({
                        content: dataForm.machineType + '下盘Ս,V不可选择',
                        duration: 5000,
                    })
                    return
                }
            }
            // } else {
            //     i2.needle = tagValue.value
            // }
        }
        const gridOption = ref()
        const gridReady = (params: any) => {
            gridOption.value = params.api
        }
        const gridOption2 = ref()
        const gridReady2 = (params: any) => {
            gridOption2.value = params.api
        }
        const sdataForm = reactive({
            atName: '',
            id: '',
            remark: '',
            firm: '',
            atCode: '',
            arrangement: '',
            deleteState: '',
            obsoleteState: '',
            createName: '',
            createTime: '',
            updateName: '',
            updateTime: '',
        })
        const numb = reactive<{ row: number[]; col: number }>({
            row: [1, 1],
            col: 1,
        })
        const sm = ref<string>('1')
        watch(
            () => dataForm.models,
            (val, oldValue) => {
                if (val === '1') {
                    //-numb.col = 1;
                    shikaishu.value = 1
                    numb.row = [1, 1]

                    //单面机
                    if (sjdata.sj.length === 2) {
                        //切换删上盘
                        sjdata.sj.splice(0, 1)
                        sjdata.sj[0] = {
                            type: '下盘',
                            typeData: [
                                {
                                    serialNumber: 1,
                                    needleName: '',
                                    needleList: [{ way: 1 }],
                                },
                            ],
                        }
                    }
                } else {
                    //双面机
                    if (sjdata.sj.length === 1) {
                        //numb.col = 1;
                        shikaishu.value = 1
                        numb.row = [2, 4]
                        let maxColNumber = 0
                        sjdata.sj[0].typeData[0].needleList.forEach((o: any) => {
                            if (o.way > maxColNumber) {
                                maxColNumber = parseInt(o.way)
                            }
                        })
                        const list = []
                        for (let i = 0; i < maxColNumber; i++) {
                            list.push({
                                needle: tagValue.value,
                                way: 1,
                            })
                        }
                        sjdata.sj.splice(0, 0, {
                            type: '上盘',
                            typeData: [
                                {
                                    serialNumber: 1,
                                    needleName: '',
                                    needleList: [
                                        {
                                            needle: '',
                                            way: 1,
                                        },
                                    ],
                                },
                                {
                                    serialNumber: 2,
                                    needleName: '',
                                    needleList: [
                                        {
                                            needle: '',
                                            way: 1,
                                        },
                                    ],
                                },
                            ],
                        })
                        sjdata.sj[1]['typeData'] = []
                        sjdata.sj[1]['typeData'].push(
                            {
                                serialNumber: 1,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 2,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 3,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 4,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            }
                        )
                    }
                }
            }
        )
        const sjhasnull = (): { way: number; type: string } | undefined => {
            let d: { way: number; type: string } | undefined = undefined
            sjdata.sj.forEach((o) => {
                o.typeData.forEach((o1: any) => {
                    o1.needleList.forEach((o2: any) => {
                        if (o2.needle == '' || o2.needle === undefined || o2.needle == null) {
                            d = { way: o2.way, type: o.type }
                            return false
                        }
                    })
                })
            })
            return d
        }
        const blList = ref<any[]>([])
        const focusBl = () => {
            post({
                url: 'product/mercery/getList',
                data: {
                    merceryName: '',
                    deleteState: '0',
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    blList.value = data
                }
            })
        }
        const blSelect = (v: string) => {
            post({
                url: 'product/mercery/getList',
                data: {
                    merceryName: v,
                    deleteState: '0',
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    blList.value = data
                }
            })
        }
        post({
            url: 'product/mercery/getList',
            data: {
                merceryName: '',
                deleteState: '0',
            },
        }).then(({ code, data }) => {
            if (code === 200) {
                blList.value = data
            }
        })

        const szList = ref<any[]>([])

        const szSelect = (v: string) => {
            let type = typeof v
            if (type == 'object') {
                v = ''
            }
            // post({
            //     url: 'product/yarnType/getList',
            //     data: {
            //         "typeName": v,
            //         "deleteState": "0"
            //     }
            // }).then(({ code, data }) => {
            //     if (code === 200) {
            //         szList.value = data
            //     }
            // })

            //纱线类别
            post({
                url: 'product/Yarn/getFieldValue',
                data: {
                    yarnName: v,
                }
            }).then(({ code, data }) => {
                if (code === 200) {
                    szList.value = data
                }
            })
        }

        const gnList = ref<any[]>([])
        const focusGn = () => {
            post({
                url: 'product/greyInformationData/select',
                data: {
                    greyInformationName: '',
                    deleteState: '0',
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    gnList.value = data
                }
            })
        }
        const gnSelect = (v: string) => {
            post({
                url: 'product/greyInformationData/select',
                data: {
                    greyInformationName: v,
                    deleteState: '0',
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    gnList.value = data
                }
            })
        }

        post({
            url: 'product/greyInformationData/select',
            data: {
                greyInformationName: '',
                deleteState: '0',
            },
        }).then(({ code, data }) => {
            if (code === 200) {
                gnList.value = data
            }
        })
        const codeGen = () => {
            if (dataForm.mercery !== '' && dataForm.feature !== '' && dataForm.yarnCountCategory !== '') {
                let gnCode = gnList.value.filter((ob: any) => {
                    return ob.greyInformationName === dataForm.feature
                })[0].greyInformation

                // let szCode = szList.value.filter((ob: any) => {
                //     return ob.typeName === dataForm.yarnCountCategory
                // })[0].typeCode
                let szCode = szList.value.filter((ob: any) => {
                    return ob.yarnName === dataForm.yarnCountCategory
                })[0].yarnCode
                let blCode = blList.value.filter((ob: any) => {
                    return ob.merceryName === dataForm.mercery
                })[0].merceryCode
                post({
                    url: 'product/pdGreyInformation/getPbbh',
                    data: {
                        processType: dataForm.processType,
                        gncode: gnCode,
                        szcode: szCode,
                        blcode: blCode,
                        greyCode: '',
                        fromGreyCode: '',
                        copyType: '',
                    },
                }).then(({ code, data }) => {
                    if (code === 200) {
                        dataForm.greyCode = data
                    }
                })
            }

            getGrayFabricName()
        }
        const psjpb = ref<any>()
        const psjpblist = ref<any[]>([])
        const psjpblistSelect = (v: any) => {
            let isOb: any = typeof v
            let val = v
            if (isOb == 'object') {
                val = ''
            }

            post({
                url: 'product/pdGreyInformation/getFieldValue',
                data: {
                    greyCode: val,
                    machineType:
                        dataForm.machineType == null
                            ? undefined
                            : dataForm.machineType == ''
                                ? undefined
                                : dataForm.machineType,
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    psjpblist.value = data
                }
            })
        }
        // 从旧坯布获取排三角信息
        const psjpbOk = () => {
            if (psjpb.value === '' || psjpb.value === null || psjpb.value === undefined) {
                Message.warning('请先选择坯布！')
                return
            }
            post({
                url: 'product/arrangementTriangleGrey/getGreyAtInfoByGreyId?id=' + psjpb.value,
            }).then(({ code, data, message }: any) => {
                if (code === 200) {
                    if (JSON.stringify(data) === '{}') {
                        Message.warning('此坯布无排三角信息！')
                        return
                    }

                    let info = data.info
                    if (info.length > 0) {
                        if (info[0].typeData.length > 0) {
                            //  numb.col = (info[0].typeData[0].needleList).length;
                            shikaishu.value = info[0].typeData[0].needleList.length
                        } else {
                            //  numb.col = 1;
                            shikaishu.value = 1
                        }
                    } else {
                        // numb.col = 1;
                        shikaishu.value = 1
                    }
                    xhCol.value = []
                    // for (let i = 0; i <= numb.col; i++) {
                    //     xhCol.value.push({ val: i })
                    // }

                    for (let i = 0; i <= numb.col; i++) {
                        xhCol.value.push({ val: i })
                    }
                    //排纱 数据
                    RendPs(2)
                    sjdata.sjid = ''
                    sjdata.atCode = data.atCode
                    sjdata.atName = data.atName
                    sjdata.remark = data.remark
                    sjdata.sj = data.info
                    if (sjdata.sj.length === 1) {
                        dataForm.models = '1'
                    } else {
                        dataForm.models = '2'
                    }
                } else {
                    Message.error(message)
                }
            })
        }
        const sp = reactive<any>({
            spdata: {},
        })
        // 商品下拉列表
        const spSelectList = ref<any[]>([])
        const focusSp = () => {
            spSelect('')
        }
        const options5 = ref<any>(spSelectList)
        const loading5 = ref(false)
        const handleSearch5 = (value: any) => {
            if (value) {
                loading5.value = true

                spSelect(value)
                options5.value = spSelectList
                loading5.value = false
            } else {
                options5.value = []
            }
        }

        // 商品下拉查询
        const spSelect = (v: string) => {
            post({
                url: 'product/Commodity/getList',
                data: {
                    commodityName: v,
                    deleteState: 0,
                    assertState: 0,
                },
            }).then(({ code, data }) => {
                spSelectList.value = data
            })
        }
        //添加商品的行数据
        const addSpRow = () => {
            //判断是否选择了商品
            if (sp.id == undefined || sp.id == '') {
                Message.warning('请选择一个商品再添加！！')
                return
            }
            // 判断商品是否被选择过
            let tempList = pageData.spRowList.filter(function (o: any) {
                return o['id'] == sp.id
            })
            if (tempList.length > 0) {
                Message.warning('选择的商品已被添加过,请勿重复添加!')
                return
            }
            //将选择的商品筛选出来
            let spList = spSelectList.value.filter(function (o: any) {
                return o['id'] == sp.id
            })
            if (spList.length > 0) {
                pageData.spRowList.push(spList[0])
            }
            pageData.spRowList.map((o: any) => {
                if ((o.isban = undefined || o.isban == null || o.isban == '')) {
                    o.isban = true
                }
            })
        }
        let selectedRowKeysSp = ref()
        //删除商品的行数据
        const delSpRow = () => {
            if (selectedRowKeysSp.value.length == 0) {
                Message.warning('请勾选一行！！')
                return
            }
            pageData.spRowList = pageData.spRowList.filter(function (o: any) {
                return !selectedRowKeysSp.value.includes(o['id'])
            })
            selectedRowKeysSp.value = []
        }

        const sptablecol: any = [
            {
                dataIndex: 'commodityCode',
                key: 'commodityCode',
                title: '商品编码',
            },
            {
                dataIndex: 'commodityName',
                key: 'commodityName',
                title: '商品名称',
            },
            {
                dataIndex: 'isban',
                key: 'isban',
                title: '是否启用',
                slotName: 'isban',
            },
            //  {
            //     dataIndex: 'brandName',
            //     key: 'brandName',
            //     title: '品牌'
            // }, {
            //     dataIndex: 'colorType',
            //     key: 'colorType',
            //     title: '染色类型'
            // },
            {
                dataIndex: 'merceryName',
                key: 'merceryName',
                title: '布料名称',
            },
            // {
            //   dataIndex: 'productType',
            //   key: 'productType',
            //   title: '产品类型',
            // },
        ]

        //排纱
        let psList = ref<any[]>([])
        //循环批量修改的数据构造
        let psEditList = ref<any[]>([])
        //装勾选的列的列数
        let checkedCol: any = []
        //改变勾的序号
        const changeXh = (val: any, num: any) => {
            psEditList.value = []
            //所有行的第几列 num i行数
            if (val.target.checked) {
                let realNum = num + 2
                if (!checkedCol.includes(realNum)) {
                    checkedCol.push(realNum)
                }
                for (let i = 0; i < psList.value.length; i++) {
                    // let ob={}
                    let ob = ''
                    if (i == 0) {
                        if (moreEdit[psList.value[i][2]['val'] + '_' + i] == undefined) {
                            moreEdit[psList.value[i][2]['val'] + '_' + i] = psList.value[i][realNum]['val']
                        }
                        ob = psList.value[i][2]['val']
                        // ob[psList.value[i][2]['val']]=""
                        // ob[psList.value[i][2]['val']]=psList.value[i][realNum]['val']
                    } else {
                        let key = psList.value[i][0]['val'] + psList.value[i][1]['val'] + '_' + i
                        let key1 = psList.value[i][0]['val'] + psList.value[i][1]['val']
                        if (moreEdit[key] == undefined) {
                            moreEdit[key] = psList.value[i][realNum]['val']
                        }
                        ob = key1
                        // ob[key1]=""
                        // ob[key1]=psList.value[i][realNum]['val']
                    }
                    psEditList.value.push(ob)
                }
            }
        }
        const visible = ref(false)
        //批量修改的弹窗
        const handleClick = () => {
            if (Object.keys(moreEdit).length > 0) {
                visible.value = true
            } else {
                Message.error('请先勾选列！')
            }
        }
        const handleBeforeOk = () => {
            //将修改的值渲染回列表里
            for (let key in moreEdit) {
                let rowNum = key.split('_')[1]
                for (let j = 0; j < checkedCol.length; j++) {
                    psList.value[parseFloat(rowNum)][checkedCol[j]].val = moreEdit[key]
                }
            }
            let inputCheck: any = document.getElementsByClassName('inputCheck')
            for (let i = 0; i < inputCheck.length; i++) {
                inputCheck[i].checked = false
            }
            checkedCol = []

            //tw加清空批量修改框的值
            for (let item in moreEdit) {
                moreEdit[item] = ''
            }
        }
        const handleCancel = () => {
            visible.value = false
            for (let key in moreEdit) {
                delete moreEdit[key]
            }
            let inputCheck: any = document.getElementsByClassName('inputCheck')
            for (let i = 0; i < inputCheck.length; i++) {
                inputCheck[i].checked = false
            }
            checkedCol = []
        }
        let moreEdit = reactive<any>({})
        //拖拽
        const handleChange = (_data: any) => {
            table.handleSuccess(_data)
        }
        //关闭弹窗时初始化数据
        const cancelPop = () => {
            pageData.showAdd = false
            psList.value = []
            xhCol.value = []
            pageData.ylCfIdList = []
            theoryPrice.value = 0
            machineUnit.value = 0
        }
        let tc: any[] = tableColumns.map((o: any) => {
            let obj = {
                headerName: o.title,
                field: o.key,
                pinned: o['fixed'],
                tooltipField: o.key,
            }
            if (o.slotName === 'edit') {
                obj['resizable'] = false
                obj['filter'] = false
                obj['sortable'] = false
                obj['lockPosition'] = 'right'
                obj['width'] = 150
                obj['cellRenderer'] = {
                    template: `<a-space><a-tag class="tagCss" @click="a" v-if="e">修改</a-tag>
                                  <a-tag class="tagCss" @click="b" v-if="f">详情</a-tag></a-space>`,
                    setup(props: any) {
                        const a = () => {
                            editHandler(props.params.data, 1)
                        }
                        const b = () => {
                            editHandler(props.params.data, 2)
                        }
                        return {
                            a,
                            b,
                            f: pageData.isInfo1,
                            e: pageData.isEdit1,
                        }
                    },
                }
            }

            return obj
        })

        let tc2: any[] = tableColumns.map((o: any) => {
            let obj = {
                headerName: o.title,
                field: o.key,
                pinned: o['fixed'],
                tooltipField: o.key,
            }
            if (o.slotName === 'edit') {
                obj['resizable'] = false
                obj['filter'] = false
                obj['sortable'] = false
                obj['lockPosition'] = 'right'
                obj['width'] = 100
                obj['cellRenderer'] = {
                    template: `<a-space><a-tag class="tagCss" @click="b" v-if="f">详情</a-tag></a-space>`,
                    setup(props: any) {
                        const a = () => {
                            editHandler(props.params.data, 1)
                        }
                        const b = () => {
                            editHandler(props.params.data, 2)
                        }
                        return {
                            a,
                            b,
                            f: pageData.isInfo1,
                        }
                    },
                }
            }

            return obj
        })
        let a = [
            {
                showRowGroup: 'hide_def',
                headerName: '',
                checkboxSelection: true,
                headerCheckboxSelection: true,
                pinned: 'left',
                width: 50,
                resizable: false,
                filter: false,
                sortable: false,
                minWidth: 50,
                maxWidth: 50,
                lockPosition: 'left',
            },
        ]
        tc = a.concat(tc)
        tc2 = a.concat(tc2)
        const defaultColDef = {
            sortable: true,
            resizable: true,
            filter: true,
            // flex: 1
        }
        //添加原料表格
        let selectedRowKeysAddYl = ref()

        const visible1 = ref(false)
        //添加原料的弹窗
        const handleClick1 = () => {
            visible1.value = true
            ylData.value.rawmaterialCode = ""
            ylData.value.materialsName = ""
            ylData.value.yarnCount = ""
        }

        const handleCancel1 = () => {
            visible1.value = false
            selectedRowKeysAddYl.value = []
            pageData.ylRowList = []
        }
        //查询要添加的有原料
        const cxYlList = () => {
            post({
                url: 'product/Rawmaterial/getInfo',
                data: ylData.value,
            }).then(({ code, data }) => {
                if (code == 200) {
                    pageData.ylRowList = data
                } else {
                    Message.error('查询失败！')
                }
            })
        }
        const ylColumns: any = [
            {
                dataIndex: 'yarnCode',
                key: 'yarnCode',
                title: '原料编号',
            },
            {
                dataIndex: 'staple',
                key: 'staple',
                title: '原料名称',
            },
            {
                dataIndex: 'colorType',
                key: 'colorType',
                title: '原料类别',
            },
            {
                dataIndex: 'merceryName',
                key: 'merceryName',
                title: '纱支',
            },
            {
                dataIndex: 'productType',
                key: 'productType',
                title: '纱支类别',
            },
            {
                dataIndex: 'processType',
                key: 'processType',
                slotName: 'processType',
                title: '是否本集团',
            },

        ]
        //添加原料列表的表单数据
        let ylData = ref({
            materialsName: '',
            rawmaterialCode: '',
            yarnCount: '',
            auditState: 1,
            processType: 0
        })

        //添加原料模糊搜索
        //下拉框得到焦点
        let selParam: any = ''
        const focusSelYl = (val: any) => {
            const ob = {}
            ob[val] = ''
            ob['auditState'] = 1
            selCxAllYl(ob)
            selParam = val
        }
        //下拉数据  坯布编号
        const optionsYl = ref<any>(pageData.codeList)
        const handleSearchYl = (value: any) => {
            if (value) {
                const ob = {}
                ob[selParam] = value
                loading.value = true
                selCxAllYl(ob)
                optionsYl.value = pageData.codeList
                loading.value = false
            } else {
                optionsYl.value = []
            }
        }

        //下拉框查询 坯布编号
        function selCxAllYl(val: any) {
            post({
                url: 'product/Rawmaterial/getRawmaterialsNameDrop',
                data: val,
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    if (selParam == 'materialsName') {
                        pageData.materialsNameList = data
                    } else if (selParam == 'rawmaterialCode') {
                        pageData.rawmaterialCodeList = data
                    } else if (selParam == 'yarnCount') {
                        pageData.yarnCountList = data
                    }
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    })
                }
            })
        }

        //判断开发编号规则
        const ExploitCodeRules = (value: string, cb: Function) => {
            return new Promise<void>((resolve) => {
                if (value != undefined) {
                    if (value.length != 10 && !value.startsWith('JFK')) {
                        cb('开发编号规则:JFK+年份2前位+月份2位+3位流水号！例如:JFK2211615')
                    }
                }
                resolve()
            })
        }
        //判断备案编号规则
        const putOnRecordsCodeRules = (value: string, cb: Function) => {
            return new Promise<void>((resolve) => {
                if (value != undefined) {
                    if (value.length != 14 && !value.startsWith('PBML')) {
                        cb('备案编号规则:PBML+年份2前位+月份2位+日期2位+4位流水号！例如:PBML2212130006')
                    }
                }
                resolve()
            })
        }
        const fabricTypeList = ref<any[]>([])
        const fabricTypeLoading = ref(false)
        const fabricTypeSelect = (value: any) => {
            if (value) {
                fabricTypeLoading.value = true
                getFabricTypeList(value)
                fabricTypeLoading.value = false
            }
        }
        const fabricTypeFocus = () => {
            getFabricTypeList('')
        }
        const getFabricTypeList = (val: any) => {
            post({
                url: 'product/pdFabric/getFieldValue',
                data: {
                    fabricType: val,
                    deleteState: 0,
                },
            }).then(({ code, data }) => {
                if (code === 200) {
                    fabricTypeList.value = data
                }
            })
        }
        //判断此列是否大于100
        const totalOnehundred = (row: any, field: any) => {
            let nums = 0
            ylTableList.value.forEach(function (o: any) {
                if (o[field] != undefined && o[field] != null && o[field] != '') {
                    nums += parseFloat(o[field])
                }
            })
            isshow.value = true
            if (nums > 100) {
                isshow.value = false
                Message.warning({
                    content: '此列不能超过100',
                    duration: 5000,
                })
                row[field] = 0
            }

            var aa = row.actualYarn - row.yarnCountProportion

            if (isNaN(aa)) {
                row.jieguo = 0 //其中一个或两个没选中的结果
                return
            }
            // var bb=shabilist.value.map((o:any,index:any)=>{
            //     if(aa>=Number(o.yarnCountMin)&&aa<=Number(o.yarnCountMax)){
            //         //在范围内
            //         return 1;
            //     }else if(aa<Number(o.yarnCountMin)||aa>Number(o.yarnCountMax)){
            //       return 2;
            //     }
            // })
            for (let item of shabilist.value) {
                if (aa >= Number(item['yarnCountMin']) && aa <= Number(item['yarnCountMax'])) {
                    row.jieguo = 1
                    break
                } else {
                    row.jieguo = 2
                }
            }
        }

        const isEng = (record: any, value: any) => {
            var isletter = /^[a-zA-Z]+$/.test(value)
            if (!isletter) {
                Message.warning({
                    content: '填写的值只能是英文！',
                    duration: 5000,
                })
                record.colorGroup = ''
            } else {
                record.colorGroup = value.toUpperCase()
            }
        }

        let jgCxArray: any = ref([])
        function focusJgCx() {
            jgCx("")
        }
        const jgCx = (ob: any) => {
            if (typeof ob == 'object') {
                ob = ""
            }
            post({
                url: 'pdm/rubberhoseSet/getInfoDropValue',
                data: {
                    rubberhoseName: ob,
                },
            }).then((res: any) => {
                if (res.code == 200) {
                    jgCxArray.value = res.data
                }
            })
        }
        const localeText1: any = ref(localeText)

        //取到所有排纱下拉框
        function focusPs() {
            post({
                url: 'dict/dictTypeDetail/getListByCodeType?codeType=19',
            }).then((res: any) => {
                if (res.code == 200) {
                    pageData.psDataList = res.data
                }
            })
        }

        const huiche = () => {
            doRefresh()
        }

        //纱长规则 路数规则
        function YarnLengthRule() {
            pageData.wayList = []
            dataForm.yarnLength = ''
            let row = psList.value
            for (var i = 1; i < row.length; i++) {
                let col = row[i]
                // let field = ''
                // for (var j = 3; j < col.length; j++) {
                //   if (col[j]['val'] != '' && col[j]['val'] != undefined && col[j]['val'] != null) {
                //     field = col[j]['val']
                //     break
                //   }
                // }
                var index1 = ''
                var index2 = ''
                if (col[1]['val'] != undefined && col[1]['val'] != null) {
                    index1 = col[1]['val']
                }
                if (col[2]['val'] != undefined && col[2]['val'] != null) {
                    index2 = col[2]['val']
                }

                if (dataForm.yarnLength == '') {
                    dataForm.yarnLength = index1 + ':' + (index2 == undefined ? "" : index2) + '=' + (ylTableList.value[i - 1]['yarnLong'] == undefined ? "" : ylTableList.value[i - 1]['yarnLong']) + 'CM'
                } else {
                    dataForm.yarnLength += ',' + index1 + ':' + (index2 == undefined ? "" : index2) + '=' + (ylTableList.value[i - 1]['yarnLong'] == undefined ? "" : ylTableList.value[i - 1]['yarnLong']) + 'CM'
                }
                // //路数
                // let numberTimes = 0
                // for (let j = 3; j < col.length; j++) {
                //   if (col[j]['val'] != "") {
                //     numberTimes++
                //   }
                // }
                // pageData.wayList.push(numberTimes)

            }
            // if (xuanhuancihu.value != null && xuanhuancihu.value != 0 && pageData.wayList.length != 0) {
            //   ylTableList.value.forEach(function (o: any, index: number) {
            //     o['wayNum'] = xuanhuancihu.value * pageData.wayList[index]
            //   })
            // }
        }
        //路数渲染  循环次数*排纱第四列开始不为空的个数
        function getWayNum() {
            pageData.wayList = []

            let row = psList.value
            for (var i = 1; i < row.length; i++) {
                let col = row[i]
                //路数
                let numberTimes = 0
                for (let j = 3; j < col.length; j++) {
                    if (col[j]['val'] != "") {
                        numberTimes++
                    }
                }
                pageData.wayList.push(numberTimes)

            }
            if (xuanhuancihu.value != null && xuanhuancihu.value != 0 && pageData.wayList.length != 0) {
                ylTableList.value.forEach(function (o: any, index: number) {
                    o['wayNum'] = xuanhuancihu.value * pageData.wayList[index]
                })
            }

            getTheoreticalYield("")
        }

        const jixing = () => {


            if (dataForm.machineType == '单面机') {

                pageData.tags = [
                    { id: '1', val: '̶' },
                    { id: '2', val: 'Ո' },
                    { id: '4', val: 'Ʌ' },
                ]
                sjdata.sj = [
                    {
                        type: '下盘',
                        typeData: [
                            {
                                serialNumber: 1,
                                needleName: '',
                                needleList: [{ way: 1 }],
                            },
                            {
                                serialNumber: 2,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 3,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 4,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                        ],
                    },
                ]

            } else {
                pageData.tags = [
                    { id: '1', val: '̶' },
                    { id: '2', val: 'Ո' },
                    { id: '3', val: 'Ս' },
                    {
                        id: '4',
                        val: 'Ʌ',
                    },
                    {
                        id: '5',
                        val: 'V',
                    },
                ]
                sjdata.sj = [
                    {
                        type: '上盘',
                        typeData: [
                            {
                                serialNumber: 1,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 2,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                        ],
                    },
                    {
                        type: '下盘',
                        typeData: [
                            {
                                serialNumber: 1,
                                needleName: '',
                                needleList: [{ way: 1 }],
                            },
                            {
                                serialNumber: 2,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 3,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 4,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                        ],
                    },
                ]
            }

            //使机型和组织排针关联
            // if (dataForm.machineType == "双间螺纹机" || dataForm.machineType == "螺纹机") {
            //     zzpzid.value = 37
            // } else if (dataForm.machineType == "双面机") {
            //     zzpzid.value = 44
            // } else if (dataForm.machineType == "单面机") {
            //     zzpzid.value = 38
            // }
            psList.value = []
            xhCol.value = []
            shuaxinpaisha()
        }

        const duiqiheight = ref(35)
        const xuanhuancihu = ref(1)
        const shikaishu = ref(1)
        const xunhuan = (val: any) => {
            if (val == '循环' || val == '实开') {
                shikaishu.value = Number(xuanhuancihu.value) * Number(numb.col)
            }
        }
        const getwuliao = (val: any) => {
            if (typeof val == 'string') {
                val = { materialName: val, auditState: 1 }
            }
            post({
                url: 'purchase/MaterialInfo/getFieldValue',
                data: val,
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    // (data as string[]).splice(0, 0, "全部");
                    //pageData.wuliaoname = data;
                    //sessionStorage.setItem("物料名称",JSON.stringify(wuliaoname.value))
                    wuliaoname.value = data
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
        }
        const wuliaoname = ref([]) as any
        const gaibian = (key: any) => {
            psList.value.forEach((o: any, index: any) => {
                ylTableList.value.forEach((b: any, index2: any) => {
                    if (index > 0) {
                        if (index - 1 == index2) {
                            if (b.yarnSource != '') {
                                if (o[1].val != undefined) {
                                    if (o[1].val == b.yarnSource) {
                                        o[1].text = b.staple
                                    }
                                }
                            }
                        }
                    }
                })
            })
        }
        const pagingList1: any = ref(pagingList)
        const machineUnit = ref(0)
        //色号
        const colornumberlist = ref([]) as any
        const colornumber = ref('')
        //色称
        const colornamelist = ref([]) as any
        const colorname = ref('')
        //等级
        const dengjilist = ref([]) as any
        const dengji = ref('')
        const getcolornumber = (val: any) => {
            if (val == '色号') {
                post({
                    url: '/product/color/getColorPage',
                    data: {
                        deleteState: 0,
                        page: 1,
                        size: 30,
                        obsoleteState: 0,
                    },
                }).then(({ data, code }: any) => {
                    if (code === 200) {
                        // (data as string[]).splice(0, 0, "全部");
                        colornumberlist.value = data.list
                        //sessionStorage.setItem("色号",JSON.stringify(data))
                        //sessionStorage.setItem("物料名称",JSON.stringify(wuliaoname.value))
                    } else {
                        Message.error({
                            content: '查询失败！',
                            duration: 5000,
                        })
                    }
                })
            }
            //         else if(val=="色称"){
            //    post({
            //         url: "/product/color/getFieldValue",
            //         data: {colorName:""}
            //     }).then(({ data, code }: any) => {
            //         if (code === 200) {
            //             console.log(data);
            //            colornamelist.value=data
            //         } else {
            //             Message.error({
            //                 content: "查询失败！",
            //                 duration: 5000,
            //             });
            //         }
            //     });
            //         }
            else if (val == '等级') {
                post({
                    url: '/product/RawmaterialLevel/getFieldValue',
                    data: { levelName: '' },
                }).then(({ data, code }: any) => {
                    if (code === 200) {
                        // (data as string[]).splice(0, 0, "全部");
                        dengjilist.value = data
                        //sessionStorage.setItem("色号",JSON.stringify(data))
                        //sessionStorage.setItem("物料名称",JSON.stringify(wuliaoname.value))
                    } else {
                        Message.error({
                            content: '查询失败！',
                            duration: 5000,
                        })
                    }
                })
            }
        }
        const isBan = (value: any) => {
            //sessionStorage.setItem("启用与禁用6666",JSON.stringify(value))
            // pageData.spRowList.map((o:any)=>{
            //     if(o.id==value.record.id){
            //         o.isban=value.isban
            //     }
            // })
        }
        const fuzhixiala = (val: any) => {
            //sessionStorage.setItem("色号色称等级",JSON.stringify(val))
            if (
                val.record.colorAccording != null ||
                val.record.colorAccording != undefined ||
                val.record.colorAccording != ''
            ) {
                val.record.colorAccording = val.item.colorName
            }
        }

        //复制工艺，颜色改编号，新增一条数据
        const iscopy = (val: any) => {
            wdbiaoji.value = 0

            //复制工艺准备的数组
            var shuzu = [
                'A',
                'B',
                'C',
                'D',
                'E',
                'F',
                'G',
                'H',
                'I',
                'J',
                'K',
                'L',
                'M',
                'N',
                'O',
                'P',
                'Q',
                'R',
                'S',
                'T',
                'U',
                'V',
                'W',
                'X',
                'Y',
                'Z',
            ]
            //复制颜色准备的数组
            var shuzu2 = [] as any
            for (var i = 1; i <= 100; i++) {
                shuzu2[i - 1] = String(i)
            }

            var shu1 = gridOption.value.getSelectedRows()[0]['greyCode'].length - 1
            var mowei = gridOption.value.getSelectedRows()[0]['greyCode'].charAt(shu1)
            var lizi = gridOption.value.getSelectedRows()[0]['greyCode'].includes('-')

            var duixiang = gridOption.value.getSelectedRows()[0]['greyCode']
            var ceshide = duixiang.substring(0, duixiang.indexOf('-'))
            if (val == '工艺') {
                if (lizi == false) {
                    shuzu.map((o: any, index: any) => {
                        if (mowei != o && index == 0) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] =
                                gridOption.value.getSelectedRows()[0]['greyCode'] + shuzu[0]
                            return
                        } else if (mowei == o) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] =
                                gridOption.value.getSelectedRows()[0]['greyCode'].substr(0, shu1) + shuzu[index + 1]
                            return
                        }
                    })
                } else if (lizi == true) {
                    var anli = duixiang.substr(0, duixiang.indexOf('-'))
                    shuzu.map((o: any, index: any) => {
                        if (anli.charAt(anli.length - 1) != o && index == 0) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] =
                                duixiang.substr(0, duixiang.indexOf('-') - 1) +
                                'A-' +
                                duixiang.substr(duixiang.indexOf('-') + 1, duixiang.length)

                            return
                        } else if (anli.charAt(anli.length - 1) == o) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] =
                                duixiang.substr(0, duixiang.indexOf('-') - 1) +
                                shuzu[index + 1] +
                                '-' +
                                duixiang.substr(duixiang.indexOf('-') + 1, duixiang.length)

                            return
                        }
                    })
                }
            } else if (val == '颜色') {
                var houliangwei = gridOption.value.getSelectedRows()[0]['greyCode']
                if (houliangwei.includes('-') == true) {
                    var a = gridOption.value.getSelectedRows()[0]['greyCode'].indexOf('-') + 1
                    var houmian = gridOption.value.getSelectedRows()[0]['greyCode'].substr(a, shu1 + 1) //获取-后面的数
                    shuzu2.map((o: any, index: any) => {
                        if (houmian == o) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] =
                                gridOption.value.getSelectedRows()[0]['greyCode'].substr(0, a - 1) +
                                '-' +
                                shuzu2[index + 1]
                        }
                    })
                } else if (houliangwei.includes('-') == false) {
                    gridOption.value.getSelectedRows()[0]['greyCode'] =
                        gridOption.value.getSelectedRows()[0]['greyCode'] + '-' + shuzu2[0]
                }
            } else if (val == '工艺颜色') {
                var houliangwei = gridOption.value.getSelectedRows()[0]['greyCode']
                if (houliangwei.includes('-') == true) {
                    var anli = duixiang.substr(0, duixiang.indexOf('-') - 1)
                    var wuyu = duixiang.substr(0, duixiang.indexOf('-'))
                    var qianmianmo = wuyu.charAt(anli.length) //-前面的字符
                    shuzu.map((o: any, index: any) => {
                        if (qianmianmo != o && index == 0) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] = anli + shuzu[0] + '-'
                        } else if (qianmianmo == o) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] = anli + shuzu[index + 1] + '-'
                        }
                    })

                    var houmiande = duixiang.substr(duixiang.indexOf('-') + 1, duixiang.length)

                    shuzu2.map((o: any, index: any) => {
                        if (houmiande == o) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] =
                                gridOption.value.getSelectedRows()[0]['greyCode'] + shuzu2[index + 1]
                        }
                    })
                } else if (houliangwei.includes('-') == false) {
                    shuzu.map((o: any, index: any) => {
                        if (mowei != o && index == 0) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] =
                                gridOption.value.getSelectedRows()[0]['greyCode'].substr(0, shu1) + 'A-1'
                            return
                        } else if (mowei == o) {
                            gridOption.value.getSelectedRows()[0]['greyCode'] =
                                gridOption.value.getSelectedRows()[0]['greyCode'].substr(0, shu1) +
                                shuzu[index + 1] +
                                '-1'
                            return
                        }
                    })
                }
            }
            jinxingfuzhi()
        }
        const panduanfuzhi = () => {
            post({
                url: 'product/Rawmaterial/getGreyDrop',
                data: { greyCode: '' },
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    // (data as string[]).splice(0, 0, "全部");
                    //sessionStorage.setItem("所有坯布编号",JSON.stringify(data))

                    data.map((o: any, index: any) => {
                        if ((o.greyCode = gridOption.value.getSelectedRows()[0]['greyCode'])) {
                            pdbiaoji.value = 1
                            //doRefresh()
                            return
                        } else if (
                            index == 0 &&
                            o.greyCode != gridOption.value.getSelectedRows()[0]['greyCode']
                        ) {
                        }
                    })
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
        }

        const jinxingfuzhi = () => {
            getsanbianhao()
            post({
                url: 'product/pdGreyInformation/select',
                data: {
                    id:
                        shenhebiaoji.value == 1
                            ? gridOption.value.getSelectedRows()[0].id
                            : gridOption2.value.getSelectedRows()[0].id,
                },
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    console.log(data);

                    caikoupaizhen.value = data.cuttingMouthNeedleGrey
                    if (caikoupaizhen.value.length != 0) {
                        caikoupaizhen.value[0]['id'] = ''
                    }

                    //原来复制的数据
                    // data.greyInformation.greyCode = gridOption.value.getSelectedRows()[0]['greyCode']
                    // data.greyInformation.id = ""
                    // var caikoupaizhen = [] as any;
                    // data.cuttingMouthNeedleGrey.map((a: any) => {
                    //     var zz = {
                    //         arrangement: a.arrangement,
                    //         pinHeader: a.pinHeader
                    //     }
                    //     caikoupaizhen.push(zz)
                    // })
                    // data.organizationPinSons.map((o: any) => {
                    //     o.id = ""
                    // })
                    // data.yarnStructures.map((o: any) => {
                    //     o.id = ""
                    // })
                    // let greyInformations=dataForm
                    //   greyInformations['machineUnit'] = machineUnit.value
                    //             greyInformations['theoryPrice'] = theoryPrice.value
                    // //准备复制的数据
                    // var obj = {
                    //     arrangementTriangle: {
                    //         atCode: data.arrangementTriangleGreys.atCode,
                    //         atName: data.arrangementTriangleGreys.atName,
                    //         info: data.arrangementTriangleGreys.info,
                    //         remark: data.arrangementTriangleGreys.remark
                    //     },
                    //     atOther: data.atOther,
                    //     machineUnit: data.greyInformation.machineUnit,
                    //     commodityGreyList: data.commodities,
                    //     cuttingMouthNeedleGrey: { pinHeader: "", arrangement: "" },
                    //     greyInformations: greyInformations,
                    //     organizationPinSon: { organizationName: "", list: data.organizationPinSons },
                    //     yarnStructure: data.yarnStructures
                    // }
                    let data1 = {}
                    data1['psj'] = {
                        atName: sjdata.atName,
                        atCode: sjdata.atCode,
                        remark: sjdata.atName,
                        info: sjdata.sj,
                    }

                    data1['ckpz'] = ckpzobj
                    data1['zzpz'] = zzpzdata.value
                    data1['yl'] = ylTableList.value
                    data1['sp'] = ''
                    // 拼接额外信息
                    let ewsjArr: any[] = []
                    ewsj.value.forEach((o: any) => {
                        ewsjArr = ewsjArr.concat(...o)
                    })
                    //新加 整合新增接口 排三角
                    let arrangementTriangle = {}
                    if (sjdata.sj.length > 0) {
                        arrangementTriangle = {
                            atName: sjdata.atName,
                            atCode: sjdata.atCode,
                            remark: sjdata.atName,
                            info: sjdata.sj,
                        }
                    }
                    let organizationPinSon = {}
                    if (data1['zzpz'] != null) {
                        let zzpzOb = zzpzListSelect.value.filter((item: any) => item.id == zzpzid.value)[0]
                        organizationPinSon = {
                            organizationName: zzpzOb == undefined ? '' : zzpzOb.organizationName,
                            list: data1['zzpz'],
                        }
                    }
                    //循环用户选中的商品 取id
                    let commodityGreyList: any = []
                    pageData.spRowList.forEach(function (o: any) {
                        commodityGreyList.push(o['id'])
                    })
                    //原料列表、
                    let yarnStructure = ylTableList.value
                    let greyInformations = dataForm
                    ckpzobj.id = undefined
                    // greyInformations['machineUnit'] = machineUnit.value
                    greyInformations['theoryPrice'] = theoryPrice.value
                    greyInformations['crossMemo'] = crossMemo.value
                    if (arrangementTriangle['info'] != null && arrangementTriangle['info'] != undefined) {
                        arrangementTriangle['info'].map((o: any) => {
                            o.typeData.map((a: any) => {
                                a.needleList.map((b: any) => {
                                    b.circulationNum = xuanhuancihu.value
                                    b.realOpenNum = shikaishu.value
                                })
                            })
                        })
                    }

                    organizationPinSon['list'].map((o: any) => {
                        o.id = ''
                    })
                    yarnStructure.map((o: any) => {
                        o.id = ''
                    })
                    greyInformations['id'] = ''
                    if (shenhebiaoji.value == 1) {
                        //未审核复制
                        post({
                            url: 'product/pdGreyInformation/getPbbh',
                            data: {
                                processType: dataForm.processType,
                                gncode: gongnengbianhao.value,
                                szcode: shazhibianhao.value,
                                blcode: buleibianhao.value,
                                greyCode: gridOption.value.getSelectedRows()[0]['greyCode'],
                                fromGreyCode: gridOption.value.getSelectedRows()[0]['fromGreyCode'],
                                copyType: fuzhixinzengindex.value,
                            },
                        }).then(({ code, data }) => {
                            if (code === 200) {
                                greyInformations['greyCode'] = data
                                var obj = {
                                    arrangementTriangle: arrangementTriangle,
                                    atOther: psList.value,
                                    machineUnit: machineUnit.value,
                                    commodityGreyList: commodityGreyList,
                                    //   cuttingMouthNeedleGrey: { pinHeader: "", arrangement: "" },
                                    cuttingMouthNeedleGrey: caikoupaizhen.value[0],
                                    greyInformations: greyInformations,
                                    // organizationPinSon: { organizationName: "", list: data.organizationPinSons },
                                    organizationPinSon: organizationPinSon,
                                    yarnStructure: yarnStructure,
                                }
                                startfuzhi(obj)
                            }
                        })
                    } else {
                        //已审核复制
                        post({
                            url: 'product/pdGreyInformation/getPbbh',
                            data: {
                                processType: dataForm.processType,
                                gncode: gongnengbianhao.value,
                                szcode: shazhibianhao.value,
                                blcode: buleibianhao.value,
                                greyCode: gridOption2.value.getSelectedRows()[0]['greyCode'],
                                fromGreyCode: gridOption2.value.getSelectedRows()[0]['fromGreyCode'],
                                copyType: fuzhixinzengindex.value,
                            },
                        }).then(({ message, code, data }) => {
                            if (code === 200) {
                                greyInformations['greyCode'] = data
                                var obj = {
                                    arrangementTriangle: arrangementTriangle,
                                    atOther: psList.value,
                                    machineUnit: machineUnit.value,
                                    commodityGreyList: commodityGreyList,
                                    cuttingMouthNeedleGrey: caikoupaizhen.value[0],
                                    greyInformations: greyInformations,
                                    // organizationPinSon: { organizationName: "", list: data.organizationPinSons },
                                    organizationPinSon: organizationPinSon,
                                    yarnStructure: yarnStructure,
                                }
                                startfuzhi(obj)
                            } else {
                                Message.error({
                                    content: message,
                                    duration: 5000,
                                })
                                pageData.showAdd = false
                            }
                        })
                    }
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
            xhCol.value = []
            for (var i = 0; i <= numb.col; i++) {
                xhCol.value.push({ val: i })
            }
        }

        //开始复制
        const startfuzhi = (val: any) => {
            post({
                url: '/product/pdGreyInformation/insertCopy',
                data: val,
            })
                .then((res: any) => {
                    if (res.code === 200) {
                        Message.success({
                            content: '复制成功',
                            duration: 5000,
                        })
                        //  pageData.showAdd = false
                        doRefresh()
                        pageData.pageLoading = false
                    } else {
                        Message.error({
                            content: res.message,
                            duration: 5000,
                        })
                    }
                })
                .finally(() => {
                    doRefresh()
                })
        }
        const pdbiaoji = ref(0)
        //根据账号判断是否为本集团
        const shifoubenjituan = () => {
            get({
                url: '/admin/acl/user/getMemberIdByJwtToken',
                data: {},
            })
                .then((res: any) => {
                    if (typeof res == 'string') {
                        Message.error({
                            content: '返回异常',
                            duration: 5000,
                        })
                    }
                    if (res.code === 200) {
                        dataForm.processType = res.data.data.judgeGroup
                        shifouxiugaibianhao.value = res.data.data.judgeGroup
                    } else {
                        Message.error({
                            content: res.message,
                            duration: 5000,
                        })
                    }
                })
                .finally(() => { })
        }
        //获取纱支比例
        const shabili = () => {
            post({
                url: '/product/YarnCountRatio/getPage',
                data: {
                    page: page.value,
                    size: size.value,
                    deleteState: '0',
                },
            })
                .then(({ data, code }: any) => {
                    if (code === 200) {
                        shabilist.value = data.list
                    }
                })
                .catch(console.log)
                .finally(() => {
                    pageData.pageLoading = false
                })
        }
        const id = ref(null)
        const shabilist = ref([])
        const isshow = ref(true)
        const theoryPrice = ref(0)
        const huixianxunhuan = () => {
            let maxColNumber = 0
            sjdata.sj[0].typeData[0].needleList.forEach((o: any) => {
                if (o.way > maxColNumber) {
                    maxColNumber = parseInt(o.way)
                }
            })
            // let n = maxColNumber - numb.col
            let n = maxColNumber - shikaishu.value
            if (n < 0) {
                for (let i = n; i < 0; i++) {
                    sjdata.sj.forEach((o: any) => {
                        o.typeData.forEach((o1: any, id: number) => {
                            o1.needleList.push({
                                way: maxColNumber + Math.abs(n - i) + 1,
                                needle: '',
                            })
                        })
                    })

                    for (let k = 0; k < psList.value.length; k++) {
                        // for (let j = 0; j < psList.value[k].length; j++) {
                        psList.value[k].push({ val: '' })
                        // }
                    }
                }
            } else if (n > 0) {
                for (let i = 0; i < n; i++) {
                    sjdata.sj.forEach((o: any, i: number) => {
                        o.typeData.forEach((o1: any) => {
                            o1.needleList.pop()
                        })
                    })
                    for (let k = 0; k < psList.value.length; k++) {
                        // for (let j = 0; j < psList.value[k].length; j++) {
                        psList.value[k].pop()
                        // }
                    }
                }
            } else {
                return
            }
            xhCol.value = []
            // for (let i = 0; i <= numb.col; i++) {
            //     xhCol.value.push({ val: i })
            // }
            for (let i = 0; i <= numb.col; i++) {
                xhCol.value.push({ val: i })
            }
        }

        const wdfz = () => {
            wdbiaoji.value++
            if (wdbiaoji.value % 2 != 0) {
            }
        }
        //重置排纱和序号列
        const shuaxinpaisha = () => {
            // psList.value=[];
            var aa = [] as any
            var old = psList.value

            for (var i = 0; i < ylTableList.value.length + 1; i++) {
                var shuzu = [] as any
                for (var j = 0; j <= 2 + numb.col; j++) {
                    if (i > 0 && j == 1) {
                        var obj2 = {
                            val: ylTableList.value[i - 1].yarnSource,
                            text: ylTableList.value[i - 1].staple,
                        }
                        shuzu.push(obj2)
                    }
                    if (i == 0 && j == 2) {
                        var obj = { val: '排纱' }
                        shuzu.push(obj)
                    }
                    if (i != 0 && j == 0) {
                        var obj = { val: '纱长(cm)' }
                        shuzu.push(obj)
                    }
                    if (i == 0 && j != 2) {
                        var obj3 = { val: '' }
                        shuzu.push(obj3)
                    }
                    if (i > 0 && j > 1) {
                        var obj3 = { val: '' }
                        shuzu.push(obj3)
                    }
                }

                aa.push(shuzu)
            }
            psList.value = aa
            psList.value.map((o: any, index1: any) => {
                o.map((a: any, index2: any) => {
                    old.map((m: any, index3: any) => {
                        m.map((n: any, index4: any) => {
                            if (index1 == index3) {
                                if (index2 == index4) {
                                    a.val = n.val
                                }
                            }
                        })
                    })
                })
            })
            //序号重写
            var xhshuzu = []
            for (var i = 0; i <= numb.col; i++) {
                xhshuzu.push({ val: i })
            }
            xhCol.value = xhshuzu
            //重写上下排针
            if (pageData.sideTitle == '修改坯布') {
                var shangpanlist = [] as any
                var xiapanlist = [] as any
                var oldpaisha = [] as any //拿到旧的排纱数据
                oldpaisha = sjdata.sj

                if (xuanzepaisanjiaolist.value.length > 0) {
                    oldpaisha = xuanzepaisanjiaolist.value
                }

                let panduanziduan = ''
                if (huancunpanduanziduan.value == '') {
                    oldpaisha.map((o: any) => {
                        panduanziduan = panduanziduan + o.type
                    })
                    huancunpanduanziduan.value = panduanziduan
                } else {
                    panduanziduan = huancunpanduanziduan.value
                }
                for (var i = 0; i < numb.row[0]; i++) {
                    var a = { serialNumber: i + 1, needleName: '', needleList: [{ needle: '', way: 1 }] }
                    shangpanlist.push(a)
                }
                for (var i = 0; i < numb.row[1]; i++) {
                    var a = { serialNumber: i + 1, needleName: '', needleList: [{ needle: '', way: 1 }] }
                    xiapanlist.push(a)
                }
                sjdata.sj = [
                    {
                        type: '上盘',
                        typeData: shangpanlist,
                        show: panduanziduan.includes('上盘') == true ? true : false,
                    },
                    {
                        type: '下盘',
                        typeData: xiapanlist,
                        show: panduanziduan.includes('下盘') == true ? true : false,
                    },
                ]

                var jj = [] as any
                sjdata.sj.map((o: any) => {
                    if (o.show == true) {
                        jj.push(o)
                    }
                })
                sjdata.sj = jj
                for (var i = 0; i < numb.col - 1; i++) {
                    //sjdata.sj[0].typeData[0].needleList.push({needle:'',way:i+2})
                    sjdata.sj.map((o: any) => {
                        o.typeData.map((a: any) => {
                            a.needleList.push({ needle: '', way: i + 2 })
                        })
                    })
                    //根据选择的排三角设置排纱
                    paishabiaoji.value++
                }
                oldpaisha.map((c: any) => {
                    c.typeData.map((d: any) => {
                        d.needleList.map((e: any) => {
                            sjdata.sj.map((o: any) => {
                                if (o.type == c.type) {
                                    o.typeData.map((a: any) => {
                                        if (a.serialNumber == d.serialNumber) {
                                            a.needleName = d.needleName
                                            a.needleList.map((q: any) => {
                                                if (q.way == e.way) {
                                                    if (q.needle == '' || q.needle == undefined) {
                                                        q.needle = e.needle
                                                    }
                                                }
                                            })
                                        }
                                    })
                                }
                            })
                        })
                    })
                })

                if (xuanzepaisanjiaolist.value.length > 0) {
                    sjdata.sj = xuanzepaisanjiaolist.value
                    //      xuanzepaisanjiaolist.value.map((c:any)=>{
                    //             c.typeData.map((d:any)=>{
                    //                 d.needleList.map((e:any)=>{
                    //                    sjdata.sj.map((o:any)=>{
                    //                     if(o.type==c.type){
                    //                       //o.show=true
                    //                         o.typeData.map((a:any)=>{

                    //        if(a.serialNumber==d.serialNumber){
                    //          a.needleName=d.needleName
                    //            a.needleList.map((q:any)=>{

                    //             if(q.way==e.way){

                    //             q.needle=e.needle

                    //           }
                    //        })
                    //          }

                    //     })
                    //                     }

                    //   })
                    //                 })
                    //             })
                    //         })

                    sjdata.sj.map((o: any) => {
                        o.typeData.map((a: any) => {
                            var changdu = a.needleList.length
                            if (numb.col - changdu >= 0) {
                                for (var i = 1; i <= numb.col - changdu; i++) {
                                    a.needleList.push({ needle: '', way: i + changdu })
                                }
                            } else {
                                var cha = changdu - numb.col
                                a.needleList.splice(numb.col, cha)
                            }
                        })
                    })
                } else {
                    sjdata.sj = oldpaisha
                    sjdata.sj.map((o: any) => {
                        o.typeData.map((a: any) => {
                            var changdu = a.needleList.length
                            if (numb.col - changdu >= 0) {
                                for (var i = 1; i <= numb.col - changdu; i++) {
                                    a.needleList.push({ needle: '', way: i + changdu })
                                }
                            } else {
                                var cha = changdu - numb.col
                                a.needleList.splice(numb.col, cha)
                            }
                        })
                    })
                }
            } else if (pageData.sideTitle == '新增坯布') {
                var laopai = sjdata.sj
                numb.row = [2, 4]
                if (sjdata.sj == undefined || sjdata.sj == null) {
                    sjdata.sj = []
                }
                console.log(xuanzepaisanjiaolist.value)
                if (xuanzepaisanjiaolist.value.length == 0) {
                    let list = []
                    for (let i = 0; i < numb.col; i++) {
                        let ob = {}
                        ob['needle'] = ''
                        ob['way'] = i + 1
                        list.push(ob)
                    }

                    if (dataForm.machineType == '单面机') {
                        sjdata.sj = [
                            {
                                type: '下盘',
                                typeData: [
                                    {
                                        serialNumber: 1,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                    {
                                        serialNumber: 2,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                    {
                                        serialNumber: 3,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                    {
                                        serialNumber: 4,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                ],
                            },
                        ]
                    } else {
                        sjdata.sj = [
                            {
                                type: '上盘',
                                typeData: [
                                    {
                                        serialNumber: 1,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                    {
                                        serialNumber: 2,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                ],
                            },
                            {
                                type: '下盘',
                                typeData: [
                                    {
                                        serialNumber: 1,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                    {
                                        serialNumber: 2,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                    {
                                        serialNumber: 3,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                    {
                                        serialNumber: 4,
                                        needleName: '',
                                        needleList: JSON.parse(JSON.stringify(list)),
                                    },
                                ],
                            },
                        ]
                    }
                } else {
                    sjdata.sj = xuanzepaisanjiaolist.value
                    //如果选择了三角，就拿三角数据
                    //       var shangpanlist=[] as any;
                    //         var xiapanlist=[] as any;
                    //              var oldpaisha=[] as any;//拿到旧的排纱数据
                    //              oldpaisha= sjdata.sj
                    //              if(xuanzepaisanjiaolist.value.length!=0){

                    //                 oldpaisha=xuanzepaisanjiaolist.value
                    //              }

                    //      let panduanziduan=""
                    //      if(huancunpanduanziduan.value==""){
                    //          oldpaisha.map((o:any)=>{
                    //         panduanziduan=panduanziduan+o.type

                    //      })
                    //      huancunpanduanziduan.value=panduanziduan
                    //      }else{
                    //            panduanziduan=huancunpanduanziduan.value
                    //      }
                    //       xuanzepaisanjiaolist.value.map((o:any,index:any)=>{
                    //            if(o.type=="上盘"){
                    //             numb.row[0]=o.typeData.length
                    //            }
                    //            if(o.type=="下盘"){
                    //              numb.row[1]=o.typeData.length
                    //            }
                    //         })
                    //            for(var i=0;i<numb.row[0];i++){
                    //         var a={serialNumber:i+1,needleName:"",needleList:[{needle:"",way:1}]}
                    //          shangpanlist.push(a)
                    //       }
                    //      for(var i=0;i<numb.row[1];i++){
                    //         var a={serialNumber:i+1,needleName:"",needleList:[{needle:"",way:1}]}
                    //          xiapanlist.push(a)
                    //       }

                    //         sjdata.sj = [
                    //     {
                    //         type: '上盘',
                    //         typeData: shangpanlist,
                    //         show:panduanziduan.includes('上盘')==true?true:false

                    //     },
                    //     {
                    //         "type":'下盘',
                    //         "typeData":xiapanlist,
                    //          show:panduanziduan.includes('下盘')==true?true:false
                    //     }

                    // ]
                    // }

                    //     for(var i=0;i<shikaishu.value-1;i++){
                    //   //sjdata.sj[0].typeData[0].needleList.push({needle:'',way:i+2})
                    //   sjdata.sj.map((o:any)=>{
                    //     o.typeData.map((a:any)=>{
                    //         a.needleList.push({needle:'',way:i+2})

                    //     })
                    //   })
                    //      //根据选择的排三角设置排纱
                    //      if(xuanzepaisanjiaolist.value.length>0){
                    //      xuanzepaisanjiaolist.value.map((c:any)=>{
                    //             c.typeData.map((d:any)=>{
                    //                 d.needleList.map((e:any)=>{
                    //                    sjdata.sj.map((o:any)=>{
                    //                     if(o.type==c.type){
                    //                         o.typeData.map((a:any)=>{

                    //        if(a.serialNumber==d.serialNumber){
                    //          a.needleName=d.needleName
                    //            a.needleList.map((q:any)=>{

                    //             if(q.way==e.way){
                    //                  if(q.needle==""){
                    //             q.needle=e.needle
                    //                  }
                    //           }
                    //        })
                    //          }

                    //     })
                    //                     }

                    //   })
                    //                 })
                    //             })
                    //         })
                    //      }

                    sjdata.sj.map((o: any) => {
                        o.typeData.map((a: any) => {
                            var changdu = a.needleList.length
                            if (numb.col - changdu >= 0) {
                                for (var i = 1; i <= numb.col - changdu; i++) {
                                    a.needleList.push({ needle: '', way: i + changdu })
                                }
                            } else {
                                var cha = changdu - numb.col
                                a.needleList.splice(numb.col, cha)
                            }
                        })
                    })
                }
            } else if (pageData.sideTitle == '复制新增') {
                var shangpanlist = [] as any
                var xiapanlist = [] as any
                var oldpaisha = [] as any //拿到旧的排纱数据
                oldpaisha = sjdata.sj

                if (xuanzepaisanjiaolist.value.length > 0) {
                    oldpaisha = xuanzepaisanjiaolist.value
                }

                let panduanziduan = ''
                if (huancunpanduanziduan.value == '') {
                    oldpaisha.map((o: any) => {
                        panduanziduan = panduanziduan + o.type
                    })
                    huancunpanduanziduan.value = panduanziduan
                } else {
                    panduanziduan = huancunpanduanziduan.value
                }
                for (var i = 0; i < numb.row[0]; i++) {
                    var a = { serialNumber: i + 1, needleName: '', needleList: [{ needle: '', way: 1 }] }
                    shangpanlist.push(a)
                }
                for (var i = 0; i < numb.row[1]; i++) {
                    var a = { serialNumber: i + 1, needleName: '', needleList: [{ needle: '', way: 1 }] }
                    xiapanlist.push(a)
                }
                sjdata.sj = [
                    {
                        type: '上盘',
                        typeData: shangpanlist,
                        show: panduanziduan.includes('上盘') == true ? true : false,
                    },
                    {
                        type: '下盘',
                        typeData: xiapanlist,
                        show: panduanziduan.includes('下盘') == true ? true : false,
                    },
                ]

                var jj = [] as any
                sjdata.sj.map((o: any) => {
                    if (o.show == true) {
                        jj.push(o)
                    }
                })
                sjdata.sj = jj
                for (var i = 0; i < numb.col - 1; i++) {
                    //sjdata.sj[0].typeData[0].needleList.push({needle:'',way:i+2})
                    sjdata.sj.map((o: any) => {
                        o.typeData.map((a: any) => {
                            a.needleList.push({ needle: '', way: i + 2 })
                        })
                    })
                    //根据选择的排三角设置排纱
                    paishabiaoji.value++
                }
                oldpaisha.map((c: any) => {
                    c.typeData.map((d: any) => {
                        d.needleList.map((e: any) => {
                            sjdata.sj.map((o: any) => {
                                if (o.type == c.type) {
                                    o.typeData.map((a: any) => {
                                        if (a.serialNumber == d.serialNumber) {
                                            a.needleName = d.needleName
                                            a.needleList.map((q: any) => {
                                                if (q.way == e.way) {
                                                    if (q.needle == '' || q.needle == undefined) {
                                                        q.needle = e.needle
                                                    }
                                                }
                                            })
                                        }
                                    })
                                }
                            })
                        })
                    })
                })

                if (xuanzepaisanjiaolist.value.length > 0) {
                    sjdata.sj = xuanzepaisanjiaolist.value
                    //      xuanzepaisanjiaolist.value.map((c:any)=>{
                    //             c.typeData.map((d:any)=>{
                    //                 d.needleList.map((e:any)=>{
                    //                    sjdata.sj.map((o:any)=>{
                    //                     if(o.type==c.type){
                    //                       //o.show=true
                    //                         o.typeData.map((a:any)=>{

                    //        if(a.serialNumber==d.serialNumber){
                    //          a.needleName=d.needleName
                    //            a.needleList.map((q:any)=>{

                    //             if(q.way==e.way){

                    //             q.needle=e.needle

                    //           }
                    //        })
                    //          }

                    //     })
                    //                     }

                    //   })
                    //                 })
                    //             })
                    //         })

                    sjdata.sj.map((o: any) => {
                        o.typeData.map((a: any) => {
                            var changdu = a.needleList.length
                            if (numb.col - changdu >= 0) {
                                for (var i = 1; i <= numb.col - changdu; i++) {
                                    a.needleList.push({ needle: '', way: i + changdu })
                                }
                            } else {
                                var cha = changdu - numb.col
                                a.needleList.splice(numb.col, cha)
                            }
                        })
                    })
                } else {
                    sjdata.sj = oldpaisha
                    sjdata.sj.map((o: any) => {
                        o.typeData.map((a: any) => {
                            var changdu = a.needleList.length
                            if (numb.col - changdu >= 0) {
                                for (var i = 1; i <= numb.col - changdu; i++) {
                                    a.needleList.push({ needle: '', way: i + changdu })
                                }
                            } else {
                                var cha = changdu - numb.col
                                a.needleList.splice(numb.col, cha)
                            }
                        })
                    })
                }
            }
            if (paishabiaoji.value >= 1) {
                xuanzepaisanjiaolist.value = sjdata.sj
            }
            paishabiaoji.value++
        }

        const wdbiaoji = ref(0)
        const xuanranpaisha = () => {
            shuaxinpaisha()
        }
        const yichu = () => {
            wdbiaoji.value = 0
        }
        const fuzhixinzeng = (val: any) => {

            if (shenhebiaoji.value == 1) {
                if (gridOption.value.getSelectedRows().length === 0) {
                    Message.error('请先勾选')
                    return
                }
                if (gridOption.value.getSelectedRows().length > 1) {
                    Message.error('只能勾选一条数据')
                    return
                }
                if (val == '工艺') {
                    fuzhixinzengindex.value = 0
                } else if (val == '颜色') {
                    fuzhixinzengindex.value = 1
                } else {
                    fuzhixinzengindex.value = 2
                }
            } else {
                if (gridOption2.value.getSelectedRows().length === 0) {
                    Message.error('请先勾选')
                    return
                }
                if (gridOption2.value.getSelectedRows().length > 1) {
                    Message.error('只能勾选一条数据')
                    return
                }
                if (val == '工艺') {
                    fuzhixinzengindex.value = 0
                } else if (val == '颜色') {
                    fuzhixinzengindex.value = 1
                } else {
                    fuzhixinzengindex.value = 2
                }
            }

            psList.value = []
            ylTableList.value = []
            zzpzSelect('')
            id.value =
                shenhebiaoji.value == 1
                    ? gridOption.value.getSelectedRows()[0]['id']
                    : gridOption2.value.getSelectedRows()[0]['id']
            // -----------
            pageData.ylCfIdList = []
            selectedRowKeys.value = []

            pageData.isDetails = false

            pageData.zhong = ''
            pageData.yin = ''
            const idToData = allDataList.filter(
                (item) =>
                    item.id ==
                    (shenhebiaoji.value == 1
                        ? gridOption.value.getSelectedRows()[0]['id']
                        : gridOption2.value.getSelectedRows()[0]['id'])
            )

            //判断本集团外加工
            post({
                url: '/product/pdGreyInformation/getState',
                data: {
                    "processType": shenhebiaoji.value == 1
                        ? gridOption.value.getSelectedRows()[0]['processType']
                        : gridOption2.value.getSelectedRows()[0]['processType'],
                },
            }).then(({ code, message }: any) => {
                if (message === "0") {
                    post({
                        url: 'product/pdGreyInformation/select',
                        data: {
                            id:
                                shenhebiaoji.value == 1
                                    ? gridOption.value.getSelectedRows()[0]['id']
                                    : gridOption2.value.getSelectedRows()[0]['id'],
                        },
                    }).then(({ code, data }) => {
                        if (code === 200) {
                            // 原料列表
                            ylTableList.value = data.yarnStructures
                            ylTableList.value.forEach(function (o: any) {
                                pageData.ylCfIdList.push(o['ylId'])
                            })
                            //tw加
                            ylTableList.value.forEach((o: any) => {
                                var cha = o.actualYarn - o.yarnCountProportion
                                for (let item of shabilist.value) {
                                    if (cha >= Number(item['yarnCountMin']) && cha <= Number(item['yarnCountMax'])) {
                                        o.jieguo = 1
                                        break
                                    } else {
                                        o.jieguo = 2
                                    }
                                }
                            })
                            // machineUnit.value = data.greyInformation.machineUnit
                            dataForm.processType = data.greyInformation.processType
                            if (data.arrangementTriangleGreys['info'] != undefined && data.arrangementTriangleGreys['info'] != null) {
                                data.arrangementTriangleGreys.info.map((o: any) => {
                                    o.typeData.map((a: any) => {
                                        a.needleList.map((b: any) => {
                                            xuanhuancihu.value = b.circulationNum
                                            shikaishu.value = b.realOpenNum
                                        })
                                    })
                                })
                            } else {
                                xuanhuancihu.value = 1
                                shikaishu.value = 1
                            }
                            console.log(xuanhuancihu.value);
                            console.log(shikaishu.value);
                            //---------------
                            // 组织排针 列数
                            colNumber.value =
                                data.organizationPinSons.length == 0 ? 1 : data.organizationPinSons.length
                            // 组织排针 数据
                            zzpzdata.value =
                                data.organizationPinSons.length == 0
                                    ? [
                                        {
                                            upBasin: '',
                                            belowBasin: '',
                                            id: '',
                                            pdOrganizationPinId: '',
                                        },
                                    ]
                                    : data.organizationPinSons
                            // 裁口排针
                            if (data.cuttingMouthNeedleGrey != null) {
                                let cuttingMouthNeedleGrey = data.cuttingMouthNeedleGrey
                                ckpzobj.id = cuttingMouthNeedleGrey.id
                                ckpzobj.pinHeader = cuttingMouthNeedleGrey.pinHeader
                                ckpzobj.arrangement = cuttingMouthNeedleGrey.arrangement
                            }
                            //tw加
                            ckpzobj.pinHeader = data.cuttingMouthNeedleGrey[0].pinHeader
                            ckpzobj.arrangement = data.cuttingMouthNeedleGrey[0].arrangement
                            // 关联商品渲染
                            pageData.spRowList = data.commodities
                            // 排三角arrangementTriangleGreys
                            sjdata.sj = data.arrangementTriangleGreys.info
                            sjdata.atCode = data.arrangementTriangleGreys.atCode
                            sjdata.atName = data.arrangementTriangleGreys.atName
                            sjdata.remark = data.arrangementTriangleGreys.remark
                            psList.value = data.atOther
                        }
                        if (sjdata.sj == undefined || sjdata.sj == null) {
                            sjdata.sj = []
                        }
                        if (sjdata.sj.length == 0) {
                            if (dataForm.machineType == '单面机') {
                                sjdata.sj = [
                                    {
                                        type: '下盘',
                                        typeData: [
                                            {
                                                serialNumber: 1,
                                                needleName: '',
                                                needleList: [{ way: 1 }],
                                            },
                                            {
                                                serialNumber: 2,
                                                needleName: '',
                                                needleList: [
                                                    {
                                                        needle: '',
                                                        way: 1,
                                                    },
                                                ],
                                            },
                                            {
                                                serialNumber: 3,
                                                needleName: '',
                                                needleList: [
                                                    {
                                                        needle: '',
                                                        way: 1,
                                                    },
                                                ],
                                            },
                                            {
                                                serialNumber: 4,
                                                needleName: '',
                                                needleList: [
                                                    {
                                                        needle: '',
                                                        way: 1,
                                                    },
                                                ],
                                            },
                                        ],
                                    },
                                ]
                            } else {
                                sjdata.sj = [
                                    {
                                        type: '上盘',
                                        typeData: [
                                            {
                                                serialNumber: 1,
                                                needleName: '',
                                                needleList: [
                                                    {
                                                        needle: '',
                                                        way: 1,
                                                    },
                                                ],
                                            },
                                            {
                                                serialNumber: 2,
                                                needleName: '',
                                                needleList: [
                                                    {
                                                        needle: '',
                                                        way: 1,
                                                    },
                                                ],
                                            },
                                        ],
                                    },
                                    {
                                        type: '下盘',
                                        typeData: [
                                            {
                                                serialNumber: 1,
                                                needleName: '',
                                                needleList: [{ way: 1 }],
                                            },
                                            {
                                                serialNumber: 2,
                                                needleName: '',
                                                needleList: [
                                                    {
                                                        needle: '',
                                                        way: 1,
                                                    },
                                                ],
                                            },
                                            {
                                                serialNumber: 3,
                                                needleName: '',
                                                needleList: [
                                                    {
                                                        needle: '',
                                                        way: 1,
                                                    },
                                                ],
                                            },
                                            {
                                                serialNumber: 4,
                                                needleName: '',
                                                needleList: [
                                                    {
                                                        needle: '',
                                                        way: 1,
                                                    },
                                                ],
                                            },
                                        ],
                                    },
                                ]
                            }
                        }
                        if (sjdata.sj.length === 1) {
                            dataForm.models = '1'
                        } else {
                            dataForm.models = '2'
                        }
                        numb.row = sjdata.sj.map((o: any) => {
                            return o.typeData.length
                        })
                        //let maxColNumber = 0
                        //tw改
                        let maxColNumber = shikaishu.value

                        //---
                        sjdata.sj[0].typeData[0].needleList.forEach((o: any) => {
                            if (o.way > maxColNumber) {
                                maxColNumber = parseInt(o.way)
                            }
                        })
                        numb.col = maxColNumber

                        shikaishu.value = maxColNumber

                        xhCol.value = []
                        numb.col = shikaishu.value / xuanhuancihu.value

                        for (let i = 0; i <= numb.col; i++) {
                            xhCol.value.push({ val: i })
                        }
                    })
                    pageData.showAdd = true
                    pageData.sideTitle = '复制新增'
                } else {
                    Message.error(message)
                }
            })

            if (idToData.length > 0) {
                for (let key in idToData[0]) {
                    dataForm[key] = idToData[0][key]
                }
            }

            ylId.value = ''

            //侧滑栏滑出滑入

            xhCol.value = []

            for (let i = 0; i <= numb.col; i++) {
                var obj = { val: i }
                xhCol.value.push(obj)
            }
        }
        const fuzhixinzengindex = ref(0)
        const huoqufuzhishuju = () => {
            let data1 = {}
            data1['psj'] = {
                atName: sjdata.atName,
                atCode: sjdata.atCode,
                remark: sjdata.atName,
                info: sjdata.sj,
            }

            data1['ckpz'] = ckpzobj
            data1['zzpz'] = zzpzdata.value
            data1['yl'] = ylTableList.value
            data1['sp'] = ''
            // 拼接额外信息
            let ewsjArr: any[] = []
            ewsj.value.forEach((o: any) => {
                ewsjArr = ewsjArr.concat(...o)
            })
            //hcw 新加 整合新增接口 排三角
            let arrangementTriangle = {}
            if (sjdata.sj.length > 0) {
                arrangementTriangle = {
                    atName: sjdata.atName,
                    atCode: sjdata.atCode,
                    remark: sjdata.atName,
                    info: sjdata.sj,
                }
            }
            let organizationPinSon = {}
            if (data1['zzpz'] != null) {
                let zzpzOb = zzpzListSelect.value.filter((item: any) => item.id == zzpzid.value)[0]
                organizationPinSon = {
                    organizationName: zzpzOb == undefined ? '' : zzpzOb.organizationName,
                    list: data1['zzpz'],
                }
            }
            //循环用户选中的商品 取id
            let commodityGreyList: any = []
            pageData.spRowList.forEach(function (o: any) {
                commodityGreyList.push(o['id'])
            })
            //原料列表、
            let yarnStructure = ylTableList.value
            let greyInformations = dataForm
            ckpzobj.id = undefined
            // greyInformations['machineUnit'] = machineUnit.value
            greyInformations['theoryPrice'] = theoryPrice.value
            if (arrangementTriangle['info'] != undefined && arrangementTriangle['info'] != null) {
                arrangementTriangle['info'].map((o: any) => {
                    o.typeData.map((a: any) => {
                        a.needleList.map((b: any) => {
                            b.circulationNum = xuanhuancihu.value
                            b.realOpenNum = shikaishu.value
                        })
                    })
                })
            }
        }

        //判断账号是本集团还是外加工，判断编号是否可以修改
        const shifouxiugaibianhao = ref(null)
        const xuanzepaisanjiaolist = ref([]) as any
        const paishabiaoji = ref(0)

        //获取纱支编号,布类编号，功能编号
        // gncode: dataForm.feature,
        //                      szcode: dataForm.yarnCountCategory,
        //                      blcode: dataForm.mercery,
        const getsanbianhao = () => {
            post({
                url: 'product/mercery/getList',
                data: {
                    merceryName: '',
                    deleteState: '0',
                },
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    data.map((o: any) => {
                        if (o.merceryName == dataForm.mercery) {
                            buleibianhao.value = o.merceryCode
                        }
                    })
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    })
                }
            })
            post({
                url: '/product/Yarn/getYarnPara',
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    data.map((o: any) => {
                        if (o.yarnName == dataForm.yarnCountCategory) {
                            shazhibianhao.value = o.yarnCode
                        }
                    })
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    })
                }
            })
            post({
                url: 'product/greyInformationData/select',
                data: {
                    greyInformationName: '',
                    deleteState: '0',
                },
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    data.map((o: any) => {
                        if (o.greyInformationName == dataForm.feature) {
                            gongnengbianhao.value = o.greyInformation
                        }
                    })
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    })
                }
            })
        }
        const buleibianhao = ref('')
        const gongnengbianhao = ref('')
        const shazhibianhao = ref('')
        const handoff = (val: any) => {
            shenhebiaoji.value = val
            doRefresh()
        }
        const shenhebiaoji = ref(1)
        const shenhe = (val: any) => {
            if (val == '待审核') {
                if (gridOption.value.getSelectedRows().length === 0) {
                    Message.error('请先勾选')
                    return
                }
                var shenhelist = [] as any
                gridOption.value.getSelectedRows().map((o: any) => {
                    var obj = {
                        id: o.id,
                        auditState: 1,
                    }
                    shenhelist.push(obj)
                })
                post({
                    url: '/product/pdGreyInformation/audit',
                    data: shenhelist,
                }).then(({ data, code, message }: any) => {
                    if (code === 200) {
                        Message.success({
                            content: simplifyMessages(message),
                            duration: 500,
                        })
                        doRefresh()
                    } else {
                        Message.error({
                            content: simplifyMessages(message),
                            duration: 5000,
                        })
                    }
                })
            } else {
                if (gridOption2.value.getSelectedRows().length === 0) {
                    Message.error('请先勾选')
                    return
                }
                var shenhelist = [] as any
                gridOption2.value.getSelectedRows().map((o: any) => {
                    var obj = {
                        id: o.id,
                        auditState: 0,
                    }
                    shenhelist.push(obj)
                })
                post({
                    url: '/product/pdGreyInformation/audit',
                    data: shenhelist,
                }).then(({ data, code, message }: any) => {
                    if (code === 200) {
                        Message.success({
                            content: simplifyMessages(message),
                            duration: 500,
                        })
                        doRefresh()
                    } else {
                        Message.error({
                            content: simplifyMessages(message),
                            duration: 5000,
                        })
                    }
                })
            }
        }
        const jitaileixing = () => {
            post({
                url: 'planSingle/machineType/getFieldValue',
                data: {
                    typeName: '',
                },
            }).then((res: any) => {
                if (res.code == 200) {
                    //pageData.machineTypeList = res.data
                    pageData.machineTypeList = []
                    res.data.map((o: any) => {
                        pageData.machineTypeList.push({ typeName: o.typeName })
                    })

                    pageData.machineTypeList = Array.from(new Set(pageData.machineTypeList))
                }
            })
        }
        const crossMemo = ref('')
        const huancunpanduanziduan = ref('')
        const shezhishikailushu = () => {
            shikaishu.value = 12
        }
        const tongbupaisha = (record: any) => {
            ylTableList.value.map((o: any, index) => {
                psList.value.map((m: any, index2) => {
                    if (index2 > 0) {
                        if (index2 - 1 == index) {
                            m.map((n: any, index3: any) => {
                                if (index3 == 1) {
                                    n.val = o.yarnSource
                                }
                            })
                        }
                    }
                })
            })
        }
        const permissionStore = usePermission()
        if (shenhebiaoji.value == 1) {
            if (permissionStore.hasPermisson('pblb.dclxg')) {
                pageData.isEdit1 = true
            }
            if (permissionStore.hasPermisson('pblb.dclxq')) {
                pageData.isInfo1 = true
            }
        } else {
            if (permissionStore.hasPermisson('pblb.yclxq')) {
                pageData.isInfo1 = true
            }
        }

        const caikoupaizhen = ref([]) as any
        //获取理论产量
        function getTheoreticalYield(record: any) {
            if (record != "") {
                if (record.yarnUnits == "" || record.yarnLong == null || record.yarnUnits == null || record.yarnLong == "" || record.yarnLong == undefined || record.yarnUnits == undefined) {
                    return
                }
            }
            if (dataForm.sumNeedleCount == "" || dataForm.sumNeedleCount == null || dataForm.loomRevolution == null || ylTableList.value.length == 0 || dataForm.sumNeedleCount == undefined || dataForm.sumNeedleCount == undefined || dataForm.loomRevolution == undefined) {
                return
            }

            post({
                url: 'product/pdGreyInformation/theoryYield',
                data: {
                    "sumNeedleCount": parseFloat(dataForm.sumNeedleCount),
                    // "sumWay": dataForm.alwaysGoes,
                    "loomRevolution": dataForm.loomRevolution,
                    "rowInfo": ylTableList.value
                }
            }).then(({ data, code, message }: any) => {
                if (code === 200) {
                    dataForm.theoreticalYield = data
                } else {
                    Message.error({
                        content: message,
                        duration: 5000,
                    })
                }
            })
            // YarnLengthRule()
        }

        const getYarnUnitsList = () => {
            post({
                url: '/dict/dictTypeDetail/getListByCodeType?codeType=33',
                data: "",
            }).then(({ data, code }: any) => {
                if (code === 200) {
                    pageData.yarnUnitsList = data
                } else {
                    Message.error({
                        content: '查询失败！',
                        duration: 5000,
                    })
                }
            })
        }
        function blurJx() {
            selectPsj(1)
            if (dataForm.machineType == '单面机') {

                pageData.tags = [
                    { id: '1', val: '̶' },
                    { id: '2', val: 'Ո' },
                    { id: '4', val: 'Ʌ' },
                ]
                sjdata.sj = [
                    {
                        type: '下盘',
                        typeData: [
                            {
                                serialNumber: 1,
                                needleName: '',
                                needleList: [{ way: 1 }],
                            },
                            {
                                serialNumber: 2,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 3,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 4,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                        ],
                    },
                ]

            } else {
                pageData.tags = [
                    { id: '1', val: '̶' },
                    { id: '2', val: 'Ո' },
                    { id: '3', val: 'Ս' },
                    {
                        id: '4',
                        val: 'Ʌ',
                    },
                    {
                        id: '5',
                        val: 'V',
                    },
                ]
                sjdata.sj = [
                    {
                        type: '上盘',
                        typeData: [
                            {
                                serialNumber: 1,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 2,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                        ],
                    },
                    {
                        type: '下盘',
                        typeData: [
                            {
                                serialNumber: 1,
                                needleName: '',
                                needleList: [{ way: 1 }],
                            },
                            {
                                serialNumber: 2,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 3,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                            {
                                serialNumber: 4,
                                needleName: '',
                                needleList: [
                                    {
                                        needle: '',
                                        way: 1,
                                    },
                                ],
                            },
                        ],
                    },
                ]
            }
        }
        function selectPsj(num: any) {
            if (num == 2) {
                if (sjid.value == "" || sjid.value == undefined || sjid.value == null) {
                    xuanzepaisanjiaolist.value = []
                }
            } else {
                xuanzepaisanjiaolist.value = []
                sjid.value = ''
            }

        }
        return {
            focusJgCx,
            selectPsj,
            getWayNum,
            blurJx,
            getYarnUnitsList,
            getTheoreticalYield,
            getwuliao,
            caikoupaizhen,
            tongbupaisha,
            huancunpanduanziduan,
            crossMemo,
            shenhe,
            shenhebiaoji,
            handoff,
            tc2,
            gridReady2,
            gridOption2,
            buleibianhao,
            gongnengbianhao,
            shazhibianhao,
            paishabiaoji,
            xuanzepaisanjiaolist,
            shifouxiugaibianhao,
            fuzhixinzengindex,
            fuzhixinzeng,
            yichu,
            xuanranpaisha,
            wdbiaoji,
            wdfz,
            theoryPrice,
            isshow,
            id,
            shabilist,
            shabili,
            wuliaoname,
            pdbiaoji,
            jinxingfuzhi,
            // iscopy,
            fuzhixiala,
            isBan,
            getcolornumber,
            colornamelist,
            colorname,
            dengjilist,
            dengji,
            colornumberlist,
            colornumber,
            machineUnit,
            gaibian,
            pagingList1,
            // getwuliao,
            xunhuan,
            xuanhuancihu,
            shikaishu,
            duiqiheight,
            jixing,
            YarnLengthRule,
            formRef1,
            huiche,
            focusPs,
            localeText1,
            jgCxArray,
            jgCx,
            isEng,
            totalOnehundred,
            zhongAndYin,
            fabricTypeList,
            fabricTypeSelect,
            fabricTypeFocus,
            putOnRecordsCodeRules,
            ExploitCodeRules,
            cxYlList,
            ylData,
            focusSelYl,
            optionsYl,
            handleSearchYl,
            ylColumns,
            selectedRowKeysAddYl,
            handleClick1,
            handleCancel1,
            visible1,
            defaultColDef,
            tc,
            cancelPop,
            handleChange,
            psEditList,
            moreEdit,
            handleClick,
            handleBeforeOk,
            handleCancel,
            visible,
            total,
            PageSize,
            change1,
            page,
            size,
            sptablecol,
            spSelectList,
            sp,
            spSelect,
            ewsj,
            psjpbOk,
            psjpblist,
            psjpb,
            psjpblistSelect,
            colNumber,
            codeGen,
            szSelect,
            gnSelect,
            blList,
            blSelect,
            gnList,
            szList,
            numb,
            tagValue,
            sm,
            setSJValue,
            sjhasnull,
            tags,
            setNum,
            setNum1,
            subRow,
            addRow,
            subCol,
            addCol,
            sjid,
            sjdata,
            sjSelect,
            sjSelectList,
            sjOk,
            copyckpz,
            ckpzobj,
            ckpzSelectList,
            ckpzadd,
            ckpzid,
            ckpzSelect,
            zzpzok,
            zzpzdata,
            zzpzListSelect,
            zzpzid,
            zzpzSelect,
            ckpzfocus,
            zzpzfocus,
            addYl,
            ylTableList,
            ylSelect,
            ylList,
            deleteHandler,
            sideOk,
            formRef,
            dataForm,
            addHandler,
            selectedRowKeys,
            pagination,
            tableColumns,
            table,
            rowKey,
            pageData,
            queryData,
            changeFirm,
            editHandler,
            tableColumns1,
            selectHandler,
            focusSel,
            focusSel1,
            focusSel2,
            focusSel3,
            focusSel4,
            focusSel9,
            focusNeedleCountList,
            searchNeedleCountList,
            searchMachineTypeList,
            focusMachineTypeList,
            searchColorAttribute,
            focusColorAttribute,
            searchUnit,
            focusunit,
            focusYl,
            changeNeedleCount,
            options,
            loading,
            handleSearch,
            options1,
            loading1,
            handleSearch1,
            options2,
            loading2,
            handleSearch2,
            options3,
            loading3,
            handleSearch3,
            options4,
            loading4,
            handleSearch4,
            ylId,
            minsZhen,
            addZhen,
            headerShow,
            focusSp,
            handleSearch5,
            options5,
            loading5,
            options6,
            loading6,
            addSpRow,
            delSpRow,
            selectedRowKeysSp,
            focusSel6,
            handleSearch6,
            changeYarnSource,
            delYl,
            focusGn,
            focusBl,
            focusSj,
            psList,
            changeXh,
            xhCol,
            gridReady,
            permissionStore,
        }
    },
    components: { Toolbar,  },
}
</script>
<style scoped lang="less">
.thead {
    white-space: nowrap;
    justify-content: center;

    .th {
        padding: 5px;
        box-sizing: border-box;
        text-align: center;
        display: inline-block;
    }

    width: 100%;
    text-align: left;
}

.tbody {
    white-space: nowrap;
    justify-content: center;

    .td {
        text-align: center;
        padding: 5px;
        box-sizing: border-box;
        display: inline-block;
    }

    text-align: left;
}

.trow>div {
    display: inline-block;
    text-align: center;
}

.active {
    width: 80px !important;
}

.arco-input-wrapper {
    padding-left: 5px !important;
    padding-right: 5px !important;
}

.arco-select-view-single {
    padding-left: 5px !important;
    padding-right: 5px !important;
}

.arco-collapse-item-content {
    padding-left: 0px !important;
    padding-right: 0px !important;
}

.demo-basic {
    padding: 10px;
    width: 200px;
    background-color: var(--color-bg-popup);
    border-radius: 4px;
    box-shadow: 0 2px 8px 0 rgba(0, 0, 0, 0.15);
}

:deep(.arco-collapse-item-active > .arco-collapse-item-header) {
    background: #00a8ea !important;
}</style>